xlearns / my-vue3-admin

0 stars 1 forks source link

mitt #12

Open xlearns opened 2 years ago

xlearns commented 2 years ago

const emitter = mitt()

// listen to an event emitter.on('foo', e => console.log('foo', e) )

// listen to all events emitter.on('*', (type, e) => console.log(type, e) )

// fire an event emitter.emit('foo', { a: 'b' })

// clearing all events emitter.all.clear()

// working with handler references: function onFoo() {} emitter.on('foo', onFoo) // listen emitter.off('foo', onFoo) // unlisten