Tiny dependency free event dispatcher
Use npm to install just run
npm install edispatcher
var dispatcher = require('edispatcher');
dispatcher.on('event', function (event, data) {
console.log('Got event with data ' + data);
});
dispatcher.send('event', 'data');
Dispatch triggered event
- event_name - name of event as string
- callback - callback function to trigger. It applies event name, passed data, source and event suscribers optional
The method returns id of subscriber
Disable trigger handler
- id - identifier of subscriber
Execute on any triggered event
- callback - callback function to trigger
Trigger new event
- event_name - name of event to be triggered as string
- data - data that should be passed
- source - trigger source