PDA

View Full Version : Best practices where and when load controllers, views,models ?



beticocorzo
20 May 2014, 5:26 AM
Hi all i'm new with Extjs 4.x, and i'm using to build my examples SA3,
so i noticed that SA creates in the App.js file, the next code:



Ext.define('MyApp.Application', {
name: 'MyApp',


extend: 'Ext.app.Application',


views: [
All my views here
],


controllers: [
All my controllers here
],


stores: [
All my stores here
]
});



So my first question is, when i run my app, all inside the app.js code are going to be loaded (All my project views, all my Stores, all my controllers)?

i mean if i load all at the same time my app is not going runs with the best performance.

I've been testing some examples that i found in the internet, and some examples does not load (some controllers, views or models) in the app.js
all these are loaded some times inside the own controllers or some times in the views ( for example in the grid)


So why SA3 put all these code in the app.js?
What is the best practice?

Thank you in advance

mitchellsimoens
27 May 2014, 9:56 AM
Architect provides what Sencha says is best practice. Controllers are to be set in app.js. Views and models do not need to be, they can be required by the classes that use them. For example, a store uses a model so the store can require the model.

beticocorzo
28 May 2014, 4:04 PM
Architect provides what Sencha says is best practice. Controllers are to be set in app.js. Views and models do not need to be, they can be required by the classes that use them. For example, a store uses a model so the store can require the model.

Ok thank you mitchellsimoens, so i understand that is not a rule load all inside the app.js, so now i'm calling my stores when i load a class or i call my views inside the controllers.