I recently stumpled over the appProperty
within the the Ext.app.Application
class and wondered why would I use it. I would require access to App instance anyway to then access a variable that again contains the instance? Maybe I am stupied but for what is this property?
I guess you have a misunderstanding here; The name
property just defines a namespace of the Application along with a getter Method for it (getApplication()
) but it will not provide you with the current instance of that application unless you call the getter or use the new appProperty
.
Lets say you have the following application
Ext.application({
name: 'App',
appProperty: 'instance',
launch: function() {
// some more code
}
});
the you can access this application from any Component by calling either
App.getApplicatio();
or
App.instance
Where the second will be bit faster cause it is no method call and for sure you can define the name of this property. So I guess you see this property is quite useful!
Note that a namespace is always a object in javascript. That is the reason why you are able to place properties into it.