View Full Version : Loading store before application launch

19 Jan 2012, 11:29 PM
Hi Friends,

I have requirement where I want load a store before launching an application. Is there any way to defer the launch till store is loaded. I am using ext-4.0.7.

Thanks and Regards
Rishi Saraf

20 Jan 2012, 12:09 AM
Just listen to the store 'load' event and start your application in your handler.

store.on('load', function() { .... });

21 Jan 2012, 6:40 AM
Just define your store in the application() method...

name: 'appName',
//appFolder: 'app',
controllers: [
//list controllers here:
stores: [
//list globally used stores here:
launch: function() {
/// your application code here... this will run _after_ your application stores have loaded...


your stores will load before the launch function is called...

21 Jan 2013, 7:13 AM
I attempted to do this and it didn't work. In my Application class I create my ViewPort in the launch function. I declared the store I need in the store array in Application like you said and the store is set to autoLoad:true. When launch is called and its creates my ViewPort that store still hasn't loaded.

What I need is before my ViewPort loads I need to load the current user into a store I defined, the creation of my ViewPort depends on this store loading first. How should I handle this? I could put a listeners on the store in launch and wait for it to load then create the viewport and that should work. But that causes an issue if in the future I want multiple store to load before.

Any ideas?

21 Jan 2013, 7:29 AM
I'm with Mankz

21 Jan 2013, 5:29 PM
Are you sure there's no error with the store? Have you run firebug and checked out the stack trace? If you need to load a store before starting your application, then you could just listen via store.on(...) and then run... However, you should not need to do this when the application method will load the store for you and make available to your functions prior to running the launch()...

I would suggest a simple unit test... See if you can just load the store and access the data. Have firebug running while you test it.