nib-forward-events
v0.2.0
Published
Forward events from a source emitter to a destination emitter.
Downloads
4
Readme
forward-events
Forward events from a source emitter to a destination emitter.
Installation
ComponentJS:
$ component install nib-health-funds/forward-events
NodeJS
$ npm install --save nib-forward-events
Usage
var
forward = require('forward-events'),
a = new Emitter(),
b = new Emitter()
;
//forward the event to another emitter
forward(a, b);
//modify the event and forward the event to another emitter
forward(a, b, function(type, args, src) {
return {
type: 'test:'+type, //prefix the event name
arguments: args
}
});
Methods
forward(src, dest, callback)
src
- The sourceEmitter
dest
- The destinationEmitter
callback
- Optional - A callback allowing the event to be modified. The callback is passed the event type, arguments and emitter. The callback should return an object with the keystype
andarguments
.