PDA

View Full Version : Is initEvents meant to be overridden by sub classes?



plleeuwm
7 Dec 2011, 11:16 AM
Is the initEvents method designed to be overridden by sub classes? Is it expected to behave like the initComponent method being that it is private but it will always exist in the framework?


Basically are these equivalent in the safety sense (afterrender is public event and supposed to fire in all 4.x versions) :


initComponent: funciton() {
this.callParent();
this.on('afterrender', this.addListeners, this);
}


or



initEvents: function() {
this.callParent();
this.addListeners();
}

tobiu
7 Dec 2011, 12:31 PM
take a look at:
http://docs.sencha.com/ext-js/4-0/source/AbstractComponent.html#Ext-AbstractComponent

the method initEvents gets called after the event "afterrender" gets fired. so i think it is meant to add DOM related events.

since both of your code sniplets do exactly the same, you can feel free to choose which one you like best.

plleeuwm
7 Dec 2011, 12:54 PM
I know currently they both do the same thing, that is not my question. My question is of the safety of initEvents, initEvents and render which calls initEvents are technically undocumented private methods. So potentially 4.2 could be released and rename the initEvents method since it is private and all of our custom classes that override initEvents will not work properly. Are these private methods guaranteed to exist between 4.x versions? Is there some kind of design document that has a list of private methods that should always exist for each class?

tobiu
7 Dec 2011, 1:35 PM
just checked back with the dev team:



It probably won't ever get removed.
Kind of falls under the same umbrella as afterRender.

plleeuwm
7 Dec 2011, 1:49 PM
just checked back with the dev team:

Thanks for checking. I'll probably stick with the 'afterrender' event.