Created
August 12, 2010 19:09
-
-
Save bmeck/521518 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var EventEmitter = require( "events" ).EventEmitter | |
, oldOn = EventEmitter.prototype.addListener | |
, id = 0 | |
module.exports = { } | |
EventEmitter.prototype.addListener = EventEmitter.prototype.on = function on(evt,cb) { | |
var capsule = { | |
source:this | |
, callback: cb | |
, event: evt | |
} | |
, myId = id++ | |
outstanding[ myId ] = capsule | |
return oldOn( evt,function callback( ) { | |
cb.apply( this, arguments ) | |
delete outstanding[ myId ] | |
} ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment