Created
March 3, 2012 09:51
-
-
Save arian/1965264 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
def(emi.prototype, "emit", function(event){ | |
var listeners = this._listeners, events, off = [] | |
this.off = function(_event, fn){ | |
if (_event == event) off.push(fn) | |
else emi.prototype.off.call(this, _event, fn) | |
return this | |
}; | |
if (listeners && (events = listeners[event])){ | |
var args = Array.prototype.slice.call(arguments, 1) | |
for (var i = 0, l = events.length; i < l; i++) events[i].apply(null, args) | |
} | |
delete this.off | |
for (var ii = 0, ll = off.length; ii < ll; ii++) this.off(event, off[ii]) | |
return this | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment