Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including propagate with all npm packages installed. Try it out:

var propagate = require("propagate")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

propagate v2.0.1

Propagate events from one event emitter into another

propagate

npm Build Status Coverage

Propagate events from one event emitter into another.

Install

$ npm install propagate

Propagate

var ee1 = new EventEmitter()
var ee2 = new EventEmitter()
propagate(ee1, ee2)

ee2.on('event', function(a, b) {
  console.log('got propagated event', a, b)
})

ee1.emit('event', 'a', 'b')

Unpropagate

You can unpropagate by ending the propagation like this:

var ee1 = new EventEmitter()
var ee2 = new EventEmitter()
var p = propagate(ee1, ee2)

// ...

p.end()

Only propagate certain events:

var ee1 = new EventEmitter()
var ee2 = new EventEmitter()
var p = propagate(['event1', 'event2'], ee1, ee2)

Propagate certain events as other events:

var ee1 = new EventEmitter()
var ee2 = new EventEmitter()
var p = propagate(
  {
    event1: 'other-event1',
    event2: 'other-event2',
  },
  ee1,
  ee2
)

License

MIT

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free