simple-event
Simple event implementation: dispatch payload to one or many listeners
Motivation
This is an essential building block for any reactive-style library or application.
Features
- Subscribe and unsubscribe listeners
- Optionally send any payload when emitting event
- Emit promises: the event will be fired off automatically when the promise resolves
Installation
npm install simple-event
Usage
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;