PDA

View Full Version : How to share objects/methods between controllers without circular references?



drunkmoose
23 Jul 2014, 11:13 AM
Pretty straightforward question. Currently, what I do when I need to access objects' methods throughout most of the application, I do this in app.js



Ext.define('Utils', {
statics: {
myMethod: function() {
return 'myResult';
}

}

});


This works, but when I build the application, I get a warning about a circular reference (app.js of course needs all the other controller classes, but then said classes refer back to app.js).

I thought of using a package including a .js file that has all the objects/methods, but sometimes, within these methods I'll need access to the Ext namespace so that won't work.

Is there any better way to do this ?

drunkmoose
24 Jul 2014, 8:09 AM
This was answered over at SO with a brilliant, MVC 'best-practice' solution.http://stackoverflow.com/questions/24916742/how-to-share-objects-methods-between-controllers-without-circular-references