Skip to content

Instantly share code, notes, and snippets.

@Raynos Raynos/readme.md
Created Aug 28, 2012

Embed
What would you like to do?
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
You can’t perform that action at this time.