Why is my ExtJS singleton not working? -


i have extjs singleton class.

as test calling method of in app.js launch() function.

but singleton static method not defined.

i thought when require class singleton becomes active?

ext.loader.setconfig({     enabled : true,     paths: {         'am': 'app'     } });   ext.application({     name: 'am',     autocreateviewport: true,       requires: [         'am.localization.resourcemanager'     ],       controllers: [         'users'     ],       launch: function() {         alert(resourcemanager.initbundleloader());     } });     ext.define('am.localization.resourcemanager', {     alternateclassname: 'resourcemanager',     singleton: true,      init: function() {         this.initbundleloader();     },      statics: {         test: 'here',         initbundleloader: function() {             debugger;             ext.applyif(ext.loader, {                 resourcebundles: new object()             });         },          registerbundle: function(bundlename, locale) {             debugger;             if(!ext.loader.hasownproperty('resourcebundles')) {                 this.initbundleloader();             }             if(!ext.loader.resourcebundles.hasownproperty(bundlename)) {                 if(ext.classmanager.iscreated('am.locale.' + locale + '.resources.' + bundlename)) {                     this.resourcebundles.bundlename = ext.create('am.locale.' + locale + '.resources.' + bundlename);                 }             }         }     } }); 

in ext js can define class singleton or define normal class statics methods. can not define statics methods in singleton.

if define class singleton ext js class post-processor creates instance of class, , in case store reference in am.localization.resourcemanager. can access singleton methods am.localization.resourcemanager.initbundleloader()

good explenation of difference between normal class statics methods , singleton can find in third post here: http://www.sencha.com/forum/showthread.php?128646-singleton-vs-class-with-all-static-members

so class definition should be:

ext.define('am.localization.resourcemanager', {     alternateclassname: 'resourcemanager',     singleton: true,      init: function() {         this.initbundleloader();     },      test: 'here',     initbundleloader: function() {         debugger;         ext.applyif(ext.loader, {             resourcebundles: new object()         });     },      registerbundle: function(bundlename, locale) {         debugger;         if(!ext.loader.hasownproperty('resourcebundles')) {             this.initbundleloader();         }         if(!ext.loader.resourcebundles.hasownproperty(bundlename)) {             if(ext.classmanager.iscreated('am.locale.' + locale + '.resources.' + bundlename)) {                 this.resourcebundles.bundlename = ext.create('am.locale.' + locale + '.resources.' + bundlename);             }         }     } }); 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -