Created
February 2, 2015 23:18
-
-
Save zxqx/ebcc00dbf592ef417431 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
module.exports = Messenger; | |
/** | |
* Event messenger | |
* @constructor | |
*/ | |
function Messenger() | |
{ | |
} | |
Messenger.prototype.trigger = function(method, args) | |
{ | |
this[method](args); | |
}; | |
Messenger.prototype.on = function(context, event, callback) | |
{ | |
this[event] = callback.bind(context); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment