vendredi 30 janvier 2015

Using requires in an "external" class vs. app.js

I've added a workspace classpath to a folder that holds a singleton class:

Code:



Ext.define('storage.WebStorage', {


singleton: true,

I then use it the config of another class (MyApp.store.TaskLists) define:

Code:



config: {
model: 'MyApp.model.TaskList',
proxy: {
type: 'offline',
url: '/test-api/test-resource.json',
storageKey: 'tasklists',
storageFacility: storage.WebStorage,
reader: {
type: 'json',
rootProperty: 'data'
}
}

When I add 'storage.WebStorage' to the requires array for the Ext.application (app.js) this works. But it does not work if I only add it to the requires array for the class that uses the singleton. I get a 'Uncaught ReferenceError: storage is not defined'

I've got another singleton class that works without using the application.requires array (required from multiple controllers). But it is located within the regular app hierarchy (app/util/MySingleton.js)

I thought it was best-practice to specify the requires at the individual class level, is there something about classes added via the workspace classpath that is different?

This is happening while serving the app from its workspace using sencha app watch.






Using requires in an "external" class vs. app.js

Aucun commentaire:

Enregistrer un commentaire