mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-22 06:49:35 +00:00
Initial commit
This commit is contained in:
commit
d76f4258f7
231 files changed
+27803
No files matched your search
@@ -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
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export interface Options {
|
||||
disabled?: Boolean
|
||||
}
|
||||
Reference in new issue
Block a user