Skip to content

Instantly share code, notes, and snippets.

@Raynos
Created August 28, 2012 03:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Raynos/3494638 to your computer and use it in GitHub Desktop.
Save Raynos/3494638 to your computer and use it in GitHub Desktop.
Re emitter

Re emitter

Create a new event emitter from another one that re-emits certain events

Example

var EventEmitter = require("events").EventEmitter
    , ReEmitter = require("re-emitter")

var first = new EventEmitter()
    , other = ReEmitter(first, ["foo", "bar"])

other.on("foo", function () {
    // fired
})

other.on("baz", function () {
    // will not fire
})

emitter.on("bar", function () {
    // will not fire
})

emitter.emit("foo")
emitter.emit("baz")
other.emit("bar")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment