0

I have 20 Stores in my app. And i'm tunning & minifying my App with sencha build. While debugging I saw a lot of [Ext.Loader] Synchronously loading warnings:

[Ext.Loader] Synchronously loading 'MyApp.store.Store1'; consider adding Ext.require('MyApp.store.Store1') above Ext.onReady

My question is, should I include once all my stores with Ext.requires(['MyApp.store.Store1' ... StoreN]) before Ext.application({ .. }); or should I include only requires: ['MyApp.store.StoreX'] in the Class that uses that store.

cualit
  • 23
  • 2
  • 7
  • For development it doesn't matter. For production - all should be minified in a single file – zerkms Jun 18 '13 at 03:46
  • But for production, do this warnings matter? – cualit Jun 18 '13 at 03:47
  • [Ext.Loader] Synchronously loading 'MyApp.store.Store1'; consider adding Ext.require('MyApp.store.Store1') above Ext.onReady – cualit Jun 18 '13 at 03:48
  • add it to `requires` property of the class that uses them http://docs.sencha.com/extjs/4.1.1/#!/api/Ext.Class-cfg-requires – zerkms Jun 18 '13 at 03:52
  • In case of my stores, I use them repeatedly in many classes. Isn't Requiring them only once at the begining of the App better than requiring them repeatedly on every file that uses them ? (this is my main concern) – cualit Jun 18 '13 at 03:57
  • is having a warning better than not having a warning? PS: you actually could check if the `Ext.Loader` is enabled and not load otherwise (in production) – zerkms Jun 18 '13 at 03:58

2 Answers2

2

Stores should be placed in the stores configuration of Ext.app.Application or specific controllers.

Then they are not only loaded at the correct time but also registered with StoreManager, so that you can access them with controller.getStore(storeId).

Christoph
  • 1,023
  • 11
  • 23
  • Thanks Christoph. I already had the stores: [...] config in my Application, and still see the warnings. I'm using extjs 4.0.7 – cualit Jun 18 '13 at 14:11
  • "Stores should be placed in the stores configuration of Ext.app.Application or specific controllers." --- if only you use the MVC layout proposed by ExtJS. Which isn't ideal and optional – zerkms Jun 19 '13 at 10:03
  • 1
    I'm using the MVC layout, and I already had the stores in the stores configuration of Ext.app.Application. The only way I could manage to get rid of all the warnings without going through every file and analyze it's store dependencies, was to add Ext.require(['MyApp.store.Store1' ... 'StoreN']. **Stores are use widely in my App, thats why I thought that requiring them ONCE was better and more practical than requiring them in every file that uses them.** If you see any downsides in this approach please let me know! – cualit Jun 19 '13 at 15:27
  • as zerkms said, there is no problem with your approach. – Christoph Jun 19 '13 at 15:53
1

The only way I could manage to get rid of all the warnings without going through every file and analyze it's store dependencies, was to add Ext.require(['MyApp.store.Store1' ... 'StoreN'].

Stores are use widely in my App, thats why I thought that requiring them ONCE was better and more practical than requiring them in every file that uses them.

If you see any downsides in this approach please let me know!

cualit
  • 23
  • 2
  • 7