Browse files

Experimental: 'on' as alias to 'addListener'

  • Loading branch information...
1 parent a6b8586 commit 515dc2161b3b6402d82102f1c0d08b19f3aaac58 @ry ry committed Jul 3, 2010
Showing with 2 additions and 1 deletion.
  1. +1 −0 lib/events.js
  2. +1 −1 test/simple/test-event-emitter-add-listeners.js
View
1 lib/events.js
@@ -75,6 +75,7 @@ process.EventEmitter.prototype.addListener = function (type, listener) {
return this;
};
+process.EventEmitter.prototype.on = process.EventEmitter.prototype.addListener;
process.EventEmitter.prototype.removeListener = function (type, listener) {
if ('function' !== typeof listener) {
View
2 test/simple/test-event-emitter-add-listeners.js
@@ -11,7 +11,7 @@ e.addListener("newListener", function (event, listener) {
events_new_listener_emited.push(event);
});
-e.addListener("hello", function (a, b) {
+e.on("hello", function (a, b) {
console.log("hello");
times_hello_emited += 1
assert.equal("a", a);

2 comments on commit 515dc21

@tj
tj commented on 515dc21 Jul 4, 2010

I like it, addEventListener is more DOM-like I guess if your heading that direction with console etc, but even addListener is pretty verbose

@aviflax

Love it!

Please sign in to comment.