emitter-proxy
v0.1.0
Published
EventEmitter add-on to allow objects to easily aggregate one instance of EventEmitter and set up chainable proxy methods for it.
Downloads
3
Readme
Usage
Browser
Currently you'll need to include EventEmitter on your own and have it exposed as "EventEmitter" in the global scope.
###Example:
var Clock = function() {
var emit = EventEmitter.proxy(new EventEmitter(), this).emit;
var timer = null;
this.start = function() {
timer = setInterval(function() { emit("tick"); }, 1000);
};
this.stop = function() { clearInterval(timer); };
};
var clock = new Clock();
NodeJS
NodeJS usage is more elegant as you're simply provided the helper function - put it where you want.
###Example:
var EventEmitter = require("events").EventEmitter;
EventEmitter.proxy = require("emitter-proxy");