0

I wanted to see how you all handle this. In our Ext.application file we have our, models, stores and controllers config arrays defined with all the models, stores in controllers in our application. Only thing is we have so many that its really unruly to keep defining each one in this file its just becoming to bloated.

Does anyone have any recommendation on how to handle such an issue. We though about just make a javascript file the just define our arrays. Then just including each array in the config object as follows:

Ext.application({
   models : MyApp.util.getModelsArray(),
   controllers: MyApp.util.getControllersArray(),
   stores: MyApp.util.getStoresArray()
})

Is there a better way, or is what a proposed above good?

b3labs
  • 960
  • 1
  • 14
  • 29

1 Answers1

1

I assume you are aware that you don't have to include all models and stores as application configs; models and stores (and views) given as configs to a controller will be loaded by the controller (when the controller is loaded by the application or dynamically). In fact, Ext.app.application inherits from the Ext.app.controller. So when you define controllers in your application, their stores and models will be loaded as well.

Considering encapsulation, reusability and proper object-oriented thinking, you should really define the stores, models and views in the controllers; and in your application only include models and stores your application methods need.

Then, how many controllers do you have? If you really have 'so many' you may want to consider only including essential ones (ie, ones that are required straight away when your application loads) and leave all other controllers to be loaded on demand. You can see how it's done in this SO answer.

Community
  • 1
  • 1
Izhaki
  • 23,372
  • 9
  • 69
  • 107
  • Thanks for the input. I miss understood the purpose of defining them in the Ext.application. – b3labs Feb 06 '13 at 01:12