-
15 Feb 2013 10:12 AM #1
Unanswered: static variables in sencha touch
Unanswered: static variables in sencha touch
hi!
when I open my app I have to do a login.. I do it and it is perfect…
(is a very easy login, no password is required..only a username)
in the others view I always put a toolBar where i want to display that username..
i tried to do this in the Controllers but i have a lot of views and i would prefer something easier, like a static varaible in java
something like:
thanks!Code://IN LOGIN VIEW: Settings.setCurrentUser(field.getValue())... //IN ALL THE OTHERS VIEWS: label.setHtml(Settings.getCurrentUser())...
-
15 Feb 2013 1:22 PM #2
You could create a class that has the needed config options. Then use the getters / setters.
Set/Get the current userCode:Ext.define('YourApplication.config.Runtime',{ singleton : true, config : { currentUser : null }, constructor : function(config){ this.initConfig(config); } });
Take a look at Ext.Class via the documents.Code:var runtime = YourApplication.config.Runtime, currentUsr; runtime.setCurrentUser('Tom'); currentUsr = runtime.getCurrentUser();


Reply With Quote