Skip to content

Instantly share code, notes, and snippets.

@anutron
Created April 23, 2009 04:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anutron/100304 to your computer and use it in GitHub Desktop.
Save anutron/100304 to your computer and use it in GitHub Desktop.
Class.events = new Events();
Class.Mutators.initialize = function(initialize){
return function(){
Class.events.fireEvent('initialize', this);
var inited = initialize.apply(this, arguments);
Class.events.fireEvent('afterInitialize', this);
return inited;
}
};
Class.events.addEvent('initialize', function(instance){
$splat(instance.Binds).each(function(name){
var original = instance[name];
if (original) instance[name] = original.bind(instance);
});
delete instance.Binds;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment