Created
October 20, 2014 02:36
-
-
Save davejachimiak/55e4bc4b422e14af427f to your computer and use it in GitHub Desktop.
ugh
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 Evented; | |
Evented = { | |
on: function(event, callback) { | |
var _base; | |
(_base = this.callbacks)[event] || (_base[event] = []); | |
return this.callbacks[event].push(callback); | |
}, | |
trigger: function(event) { | |
var args, callbacks; | |
args = Array.prototype.slice.call(arguments, 1); | |
if (callbacks = this.callbacks[event]) { | |
return callbacks.forEach((function(_this) { | |
return function(callback) { | |
return callback.apply(_this, args); | |
}; | |
})(this)); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment