Question

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

Was it helpful?

Solution

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
}
})

OTHER TIPS

(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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top