Skip to content

Instantly share code, notes, and snippets.

@natecavanaugh
Created October 31, 2012 16:56
Show Gist options
  • Save natecavanaugh/3988272 to your computer and use it in GitHub Desktop.
Save natecavanaugh/3988272 to your computer and use it in GitHub Desktop.
Show ordering of hierarchy and method invocation during instantiation
var first1 = function(c){
this.__NAME = this.constructor.NAME;
console.log('first1 constructor', this.__NAME);
first1.superclass.constructor.apply(this, arguments);
};
first1.NAME = 'first1';
A.extend(first1, A.Widget, {
initializer: function(){
this._myFn();
},
_myFn: function(){
console.log('first1: myFn');
}
});
var second1 = function(c){
second1.superclass.constructor.apply(this, arguments);
console.log('second1 constructor', this.__NAME);
};
second1.NAME = 'second1';
A.extend(second1, first1, {
_myFn: function(){
this._anotherFn();
},
_anotherFn: function() {
console.log('second1: _anotherFn');
}
});
//new second1({});
var third1 = function(c){
third1.superclass.constructor.apply(this, arguments);
console.log('third1 constructor', this.__NAME);
};
third1.NAME = 'third1';
A.extend(third1, second1, {
_myFn: function(){
console.log('third1: myFn');
}
});
var noInheritClass = function(c) {
console.log('noInheritClass constructor; name: %s', this.__NAME);
};
noInheritClass.prototype = {
_myFn: function(){
this._anotherFn();
},
_anotherFn: function() {
console.log('noInheritClass: _anotherFn');
}
}
A.Base.build(third1.NAME, third1, [noInheritClass], null, {dynamic: false});
var fourth1 = A.Base.build('fourth1', third1, [noInheritClass]);
new third1({});
new fourth1({});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment