extjslocal-storagedatastoredelayed-executionsenchatouch-2.4

Way to load/access all stores in Sencha project


I need to retrieve a security token and use it in all my stores to load them.
I could put autoLoad to false, make an event that gets each of my stores and calls the load event:

Ext.getStore('one').load();
Ext.getStore('two').load();

But I'd rather not have add a line every time I add a store. Is there a way to access or loop through all stores and load them? Or have an observer and make the stores wait until a value is available in LocalStorage before they load?

Note: I know about the stores property in app.js but they contain the full classnames, not the store id's.


Solution

  • Just load the first store that retrieves the token (store it in a cookie or a global variable) then in the load event of that token loading store, do a Ext.StoreManager.each(function(store) { //code... }) loop.

    Obviously, in that loop, skip over the token loading store.