Pregunta

How to create a custom folder inside the sencha's app directory. i wanted to have a directory called service (which just holds all the service related js files) inside app directory. and i wanted to include it in the app.js just like view, controller files.

is it possible to do it? if not what is the best way to do it?

right now i have added all the js files inside the service folder in app.json

thanks

¿Fue útil?

Solución

Yes, you can do this.

Just create a folder manually inside app folder and instantiate the classes whenever required by calling it with requires : [].

example usage :

requires: ['MyApp.service.primeService']

include the above line in app.js where MyApp is the application name and service is the custom folder, primeService is the custom js file.

app.js might be as follows :

Ext.application({
name: 'MyApp',
appFolder: 'app-demo',   
extend: 'Ext.app.Application',  
requires: ['MyApp.service.primeService'],
launch: function(){
    //code here
}
})

Otros consejos

(Sub)folders in app folder are mapped to class names. You can create subfolder but then class names must match. For example, you want to have MyClass in service subfolder. Then you must define the class this way:

Ext.define('MyApp.service.MyClass', {....})

And you must put it in requires array in the Application:

requires:['MyApp.service.MyClass']

See this guide for details

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top