Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Siphon multiple event listeners to a single function.
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib initial commit
test initial commit
.gitignore initial commit
.npmignore
.travis.yml
Makefile initial commit
index.js
package.json
readme.md

readme.md

Siphon

Siphon multiple event listeners to a single function.

Build Status

Installation

Works with Express 3.0.x

$ npm install siphon

Usage

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 (emitter1Args, emitter2Args) {
  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);

API

siphon(eventName, emitters, callback)

  • @param {String} eventName
  • @param {Array} emitters
  • @param {Function} callback
Something went wrong with that request. Please try again.