event-bus-station
v1.0.0
Published
Simple event bus.
Downloads
24
Readme
event-bus-station
Simple event bus.
Usage
import {EventBus} from 'event-bus-station'
const bus = new EventBus()
const callback = function (data: any) {
console.log(data)
}
bus.once('mount', callback) // single use
bus.on('update', callback)
bus.emit('mount', {a: '1'})
bus.emit('update', {b: '2'})
bus.off('update', callback)
bus.off('update') // remove all listener on 'update'