1.0.3 • Published 10 years ago

simple-dispatcher v1.0.3

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

simple-dispatcher

NPM version build status Test coverage Downloads

Attach multiple listeners to a single emitter.

Installation

npm install simple-dispatcher

Usage

var dispatcher = require('simple-dispatcher');
var EventEmitter = require('events').EventEmitter;
var emitter = new EventEmitter();

dispatcher(emitter, {
  myEvent: [fn1, fn2],
  end: fn3
});

function fn1() {};
function fn2() {};
function fn3() {};

// dispatch event
emitter.emit('myEvent', {foo: 'bar'});

See also

License

MIT