PDA

View Full Version : Keeping references in component getters



IHaveRead
30 Jan 2010, 10:16 PM
Hai guise,

first, if any of the developers read this, THANK YOU! ExtJS is art.

First, i'm not sure if i'm doing it rite. In my components i use getter functions to get references to child components.

For example:



ExtApp.MyPanel = Ext.extend(Ext.Panel, {
getSomeComponent: function() {
return this.get('someComponentsContainer').get('someComponentItemId');
}
});


This works pretty good, however i asked myself if it would be smart to keep a reference to the component "at hand" to save the lookup in the component manager?



ExtApp.MyPanel = Ext.extend(Ext.Panel, {
someComponentRef: undefined,
getSomeComponent: function() {
if (this.someComponentRef==undefined)
this.someComponentRef = this.get('someComponentsContainer').get('someComponentItemId');
return this.someComponentRef;
}
});


Thanks for your thoughts!
Regards

evant
30 Jan 2010, 10:27 PM
It would save some lookup time, but any kind of performance gains would be fairly negligible.

IHaveRead
30 Jan 2010, 10:31 PM
Thanks for the quick answer!

Animal
31 Jan 2010, 12:35 AM
Check the ref config.