In java and C++ we could store a variable globally and access its value from any where in the project.
Say, i am inside a class called Residence
and i am saving the residenceNumber
which is a INT
to a global variable called houseNumberGlobalVariable
.
Now, i could access houseNumberGlobalVariable
from any class in the project. In a similar fashion, is there a Global variable in EXTJS
that i could use.
I need to set a value from one class and access it from another. What is the equivalent in EXT JS. I don't think there's a global variable concept in EXTJS, but what is the equivalent in it ?
Create a special class and put all your global
variables there.
Ext.define('MyApp.global.Vars', {
singleton: true,
....
houseNumberGlobalVariable: undefined
});
This way if you need access for it anywhere in the code just use MyApp.global.Vars.houseNumberGlobalVariable