Initial commit

This commit is contained in:
Matej Glasnák committed 2022-11-21 05:42:38 +01:00
commit d76f4258f7
231 files changed
+27803

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
# W / Events
- This plugin will add mitt global events to your app
- https://www.npmjs.com/package/mitt
# Required third-party plugins
`$ npm i mitt@2`
# Import in `main.ts`
```javascript
import events from '@/plugins/w/events'
const app = createApp(App)
.use(events)
```
# Examples
1. Listen for event
```javascript
this.eventBus.on('eventname', (optionalData) => ...do something)
```
2. Listen for all events
```javascript
this.eventBus.on('*', (optionalData) => ...do something)
```
3. Fire event
```javascript
this.eventBus.emit('eventname', optionalData)
```
4. Clear all event listeners
```javascript
this.eventBus.all.clear()
```
5. More on https://www.npmjs.com/package/mitt
+11
View File
@@ -0,0 +1,11 @@
import { Options } from './types'
import mitt from 'mitt'
export default {
install: (app, options: Options) => {
if (options && options.disabled === true) return
const eventBus = mitt()
app.config.globalProperties.eventBus = eventBus
}
}
+3
View File
@@ -0,0 +1,3 @@
export interface Options {
disabled?: Boolean
}