0.1.0 • Published 11 years ago

emitter-proxy v0.1.0

Weekly downloads
1
License
-
Repository
github
Last release
11 years ago

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");