A subscribe & pubscribe module
IE / Edge | Firefox | Chrome | Safari | iOS Safari | Opera |
---|---|---|---|---|---|
IE8+ Edge+ | last 10 versions | last 10 versions | last 2 versions | last 2 versions | last 2 versions |
yarn add zax-eventbus --save
import EventBus, { EventHandler, EventHandlers, EventOptions, EventSource } from 'zax-eventbus'
const eventbus = new EventBus({
channel: 'default',
debug: false
})
eventbus.on('foo', handler)
eventbus.once('qux', handler)
eventbus.emit('foo', 'bar')
eventbus.off('foo')
eventbus.get('foo')
eventbus.has('foo')
eventbus.keys()
eventbus.values()
eventbus.remove('foo')
eventbus.removeAll()