Search code examples
extjsextjs6-classic

extjs Ext.app.Application for custom package


I am trying to create a package, but it has a bunch of required files and global stores that need to be fetched when the application start. My package used to be part of a larger application, so I had these added to requires: [] and stores: [].

How do we achieve this now that I have a separate package? (Where I no longer have an Application.js file)

Update

I have added a Require.js file that contains all the requires for my package. Now I am left with emulating Application.stores for creating global stores.


Solution

  • Just add dependencies straight to the classes on which they depend (with help requires). In case this store will have to be initialized manually

    Answer on update:

    Try override constructor of Require class

    
    Ext.define('Require', {
        stores:[],
        constructor: function (config) {
            this.callParent(arguments);
            Ext.Array.each(this.stores, function (storeName) {
                Ext.require(storeName, function () {
                    Ext.create('storeName', {});
                })
            })
        }
    })