1.0.4 • Published 6 years ago

on-emit v1.0.4

Weekly downloads
12
License
ISC
Repository
github
Last release
6 years ago

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