emitter20
An event emitter that used to be 20 lines of code but is still quite small. No dependencies.
Install
$ npm install --save emitter20
Methods
on: (eventName: string, callback: Function) => void
- Subscribe a callback to the given event type.off: (eventName: string, callback: Function) => void
- Remove a callback from the given event type.trigger: (eventName: string, callback: Function) => void
- Trigger an event, invoking all subscribers.clear: (eventName?: string) => void
- Remove all subscribers from the given event type, or all subscribers if no event type is specified.
Usage
var Emitter = var emitter = emitter emitter // Haiaaaaa!'
Pass arbitrary data to the event handler:
var emitter = emitter emitter // Welcome bob!
Can be used as a mixin:
var assign = var obj = a: 1 b: 2 obj obj // Haiaaaaa!'
License
ISC © Raine Revere