PDA

View Full Version : Helper Classes



jschwartz73
9 Feb 2012, 8:59 PM
Hello,

I'm new to Sencha Designer. I've been playing around with Sencha Touch 2 since Developer Preview 1.

What is the appropriate way to create a helper / utility class. A class that is not a controller, view, model or store?

For example, I have the following class in one of my ST2 apps. The purpose of this class is to manage the security token for the app. In designer, I'm able to fire an event to another controller which would work fine for the setToken below, but how would I call the getToken method. Obviously, controller to controller communication is frowned on.

The code is below. Any help would be greatly appreciated.



Ext.define('App.util.SecurityHelper', {
singleton : true,

isTokenValid: function(token) {
if (!token || token == null) {
return false;
}

return true;
},

setToken: function(newToken) {
this.token = newToken;
},

getToken: function() {
return this.token;
}

});


Thanks in advance.

Sincerely,
Jeff Schwartz

Phil.Strong
10 Feb 2012, 12:08 PM
The quick answer is there is no way to do this at the moment inside Designer.

You can however include js files not created by designer in your app directory and include those in an index.html file you create based on designer.html