zax-eventbus
v1.0.2
Published
zax-eventbus
Downloads
2
Maintainers
Readme
Event bus
A subscribe & pubscribe module
Browsers support
| 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 |
Install
yarn add zax-eventbus --save
Usage
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()