Dead simple event bus that can be used in Browsers and Node.js
Installation
Available via npm
npm install dead-simple-event-bus
Public API
It as 3 methods.
- add()
- remove()
- trigger()
API can be used in 3 ways , namely
- Single event
- Multiple events with args style
- Multiple events with array style
Browser Setup
node module
var EventBus = EventBus;var ebSingle = ;var ebArgsStyle = ;var ebArrayStyle = ;
Single event
//event Bus with single event ebSingle;ebSingle;ebSingle;
Multiple events with args style
ebArgsStyle;ebArgsStyle;ebArgsStyle;
Multiple events with array style
ebArrayStyle;ebArrayStyle;ebArrayStyle;
Duplicate functions
dead-simple-event-bus optimizes the event bus by not allowing more than one copy of function to be added.
ebSingle; // assigns event ebSingle; // avoids assigning and prints message
By default , duplicate functions print a message to console and doesn't get addedup again on the event bus. If you want to handle this manually , you could dig a bit into the source and insert a callback.
Contribution
More than welcomed !