PDA

View Full Version : aproach to proceed after 3 stores are loaded



dedoz
12 Feb 2012, 7:09 AM
to execute a code after more than one store is loaded (asyn) i use

(this code is just an example)


store1 = Ext.create('StoreType1');
store2 = Ext.create('StoreType2');
store3 = Ext.create('StoreType3');

store1.load{callback: allStoresReady(); }
store2.load{callback: allStoresReady(); }
store3.load{callback: allStoresReady(); }

function allStoresReady ()
{ if ( store1.isLoading() || store2.isLoading() || store3.isLoading() ) return;

... execute some code after all stores are ready .....
}



is this the right way to go ?

mitchellsimoens
12 Feb 2012, 8:10 AM
It's one way to go that will work.

jay@moduscreate.com
16 Feb 2012, 11:01 AM
to execute a code after more than one store is loaded (asyn) i use

(this code is just an example)


store1 = Ext.create('StoreType1');
store2 = Ext.create('StoreType2');
store3 = Ext.create('StoreType3');

store1.load({callback: allStoresReady });
store2.load({callback: allStoresReady });
store3.load({callback: allStoresReady });

function allStoresReady ()
{ if ( store1.isLoading() || store2.isLoading() || store3.isLoading() ) return;

... execute some code after all stores are ready .....
}



is this the right way to go ?

I fixed your code. You need to set the callback as the reference of the function, not the result of execution.

It is the best way to go since the store loads are asynchronous.