node package manager

event-relay

event-relay

event-relay is a little module for proxying events through arbitrary emitters. It will work with any event emitter implementation (EventEmitter, emitter-component, asEvented, etc) that exposes an emit() method.

Build status

Browser support

Install

$ npm install event-relay

API

event-relay(

  event (string):
    the name of the event that
    will be emitted

  emitter (event_emitter):
    the proxy who will emit the
    aforementioned event. must 
    have an emit() method

)

Usage

var EventEmitter = require('events').EventEmitter
var relay = require('event-relay')
 
var source = new EventEmitter
var proxy = new EventEmitter
 
proxy.on('relayed-event', function(data) {
  // { some: 'data' } 
})
 
source.on('event', relay('relayed-event', proxy))
source.emit('event', { some: 'data' })

License

MIT