simple-events-bus
v0.2.0
Published
simple eventbus based on fbemitter
Downloads
2
Maintainers
Readme
simple-events-bus
simple eventbus based on fbemitter
Usage
basic :
import eventBus from 'simple-events-bus';
// one listener
eventBus.addListener('key', _ => {
// do something
});
// multiple listener
eventBus.addListeners('key', _ => {
// do something
});
// get all listeners keys that has `key` in there name, like `key-dsfy`, `key-something`, ...
eventBus.getListenersOf('key');
// to remove a listener
eventBus.removeListener('key');
// to remove all listeners
eventBus.removeAllListeners();
// to remove all listeners with name has with `key` in there name
eventBus.removeListenersOf('key');
// to emit a event
eventBus.emit('key');
// to emit a event to all subscribed event that has `key` in there name
// `key` `key-test` `key-something` all theses event will be triggered
eventBus.emitAll('key');
// check if listener exist
eventBus.listenerExist('key');
//get EventEmitter Instance
eventBus.getInstance();