on-emit
v1.0.4
Published
Simple, fast, functional event emitter
Downloads
35
Maintainers
Readme
On Emit
Simple, fast, event emitter with a minimal but rich API
- Tiny
- 100% test coverage
- rich API
- performant
- zero dependencies
Installation
npm install on-emit
Usage
var create = require('on-emit')
var emitter = create()
var dispose = emitter.on('a', log)
emitter.emit('a', { data: true }) // logs
dispose() // removes specific listener
emitter.off() // removes all listeners
emitter.off('a') // removes all listeners for 'a' namespaced events
emitter.off('a', log) // removes all listeners for 'a' namespaced events with 'log' handler
emitter.on('*', log) // logs all events
function log (type, data) {
console.log(type, data)
}