We use ExtJS 3.x pretty heavily within our flagship application. Our application's admin area is split into the different modules that we offer. Each module, and subsequently each page for the different CRUD actions of the module have their own .js file to handle the functionality.
When we started, we were just throwing all of our code into Ext.onReady()
and not really worrying about the global namespace (hey... we never really thought of ourselves as javascript developers). After getting the hang of ExtJS, I moved to using the singleton pattern and calling the init method from Ext.onReady()
like so.
var newModule = {
propertyOne: 'asfd',
propertyTwo: 'asdf',
init: function() {
// set up
}
};
Ext.onReady(function() {
newModule.init();
});
Is this a correct use of the javascript singleton pattern and are there any patterns that fit ExtJS better than singleton, like say maybe the Module Pattern?
I've been using this guide as a starting point to learning design patterns in Javascript.
We eventually decided to upgrade to ExtJS and it seems with the new MVC architecture in place the best way to design your ExtJS software is using Ext.application()
You can read about it here.