on-emit

1.0.4 • Public • Published

Travis CI devDependency Status js-standard-style

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)
}

Package Sidebar

Install

npm i on-emit

Weekly Downloads

5

Version

1.0.4

License

ISC

Unpacked Size

7 kB

Total Files

5

Last publish

Collaborators

  • alz