I have done some research on the ExtJS forum regarding private methods and fields inside a extended class, and I couldn't find any real answer to this.
And when I say an extended class I mean something like this:
Ext.ux.MyExtendedClass = Ext.extend(Ext.util.Observable, {
publicVar1: 'Variable visible from outside this class',
constructor: function(config) { this.addEvents("fired"); this.listeners = config.listeners; }, // to show that I need to use the base class
publicMethod1: function() { return 'Method which can be called form everywhere'; },
publicMethod2: function() { return this.publicMethod1() + ' and ' + this.publicVar1; } // to show how to access the members from inside another member
});
The problem here is that everything is public. So, how do I add a new variable o method within the scope of MyExtendedClass that cannot be accessed from outside but can be access by the public methods?
I use something like the following.
@Protron: Your answer is awesome! Thanks! I went a little bit further and created my own class extender method.
This way we can save some extra "()", and we have the "Ext.reg" called for free. []s
The following example shows the Upper Stage way to define privileged private & public members. But it also shows how to define private static members (also called class members), and public non-privileged members. Using these last 2 instead of the privileged ones, we will reduce initialization time as they are not parsed every time you create a new object of your class: