Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

easy-emitter

fritx140.0.2

Easy event emitter implementation

readme

easy-emitter

Easy event emitter implementation

Usage

Node Module

var Emitter = require('easy-emitter')
Emitter.call(buddy) // become emitter
buddy.on('kick', function onKick(){
  console.log('ouch~')
  if (++this.kickCount >= 5) {
    this.off('kick', onKick)
    console.log('you are dead~')
  }
})
_.times(100, function(){ buddy.emit('kick') })

On Browser

// easy-emitter.js loads
var Emitter = window.EasyEmitter

Emitter Methods

  • on(key, fn)
  • one(key, fn)
  • off(key, [fn])
  • emit(key, [*arguments])