I have a set of combo boxes that are driven by five stores and I want to fire a function once all the stores are completely loaded. What is the recommended way of doing this? I could do something like this but it feels kludgy:
var store1Loaded = false;
var store2Loaded = false;
store1.on('load', function(){
store1Loaded = true;
});
store2.on('load', function(){
store2Loaded = true;
});
store1.load();
store2.load();
function WaitForFunction()
{
if (!store1Loaded || !store2Loaded)) {
setTimeout( WaitForFunction, 100);
return;
}
AllStoresLoaded();
}
function AllStoresLoaded(){
//Do Something
}
Use the
store.isLoading()method, I think that is what it is for. I use it and it works fine.Configure the stores that you want to be loaded before performing
some logic with a
storeIdconfig.Put these
storeIdsinto an array.Whenever one of these stores is loaded iterate through the array, lookup the store with
Ext.getStoreand callisLoadingon it.If none of the stores in the array are still loading, perform your logic.
For example, say I want
store1andstore2loaded before I perform some logic (I am showing this in non-MVC pattern because it looks like you are not using MVC pattern from your snippet).