Posted on 11/01/2011. By Pete Otaqui.
I’ve added some more features to the EventEmitter mixin (like actually working listener removal) and posted it to github:
It’s fairly simple to use … something like this:
var MyKlass = function() {}; EventEmitter.augment(MyKlass.prototype); /** * Show me * * @fires shown */ MyKlass.prototype.showMe = function() { this.trigger('shown', {'visible':true}); } var myInstance = new MyKlass(); myInstance.on('shown', function(e) { console.log(e.visible); } myInstance.showMe();