siphon

Siphon multiple event listeners to a single function.

Siphon

Siphon multiple event listeners to a single function.

Works with Express 3.0.x

$ npm install siphon

Siphon will add a one time listener to each emitter in the emitter array

// require it 
var siphon = require('siphon'),
    EventEmitter = require('events').EventEmitter
    emitter1 = new EventEmitter(),
    emitter2 = new EventEmitter();
 
// siphon an event 
siphon('init', [emitter1, emitter2], function (emitter1Argsemitter2Args) {
  console.log('Both emitters have fired!');
  console.log(emitter1Args[0] === emitter1);
  console.log(emitter2Args[0] === emitter2);
});
 
// Fire the events 
console.log('Firing emitter 1');
emitter1.emit('init', emitter1);
console.log('Firing emitter 2');
emitter2.emit('init', emitter2);
  • @param {String} eventName
  • @param {Array} emitters
  • @param {Function} callback