Simple event implementation: dispatch payload to one or many listeners
This is an essential building block for any reactive-style library or application.
- Subscribe and unsubscribe listeners
- Optionally send any payload when emitting event
- Emit promises: the event will be fired off automatically when the promise resolves
npm install simple-event
var simpleEvent = ;// Create eventvar myEvent = ;// Subscribe a functionmyEvent;myEvent;// Subscribe function in some contextmyEvent;// Emit eventmyEvent;// Emit some messagemyEvent;// Emit promise: the event will be fired when the promise is resolvedvar myData = $http;myEvent;// UnsubscribemyEvent;