Extjs 在应用程序创建和需求之前启动代码

Extjs 在应用程序创建和需求之前启动代码,extjs,launch,onbeforeload,Extjs,Launch,Onbeforeload,我对正确实现代码的最佳方法有疑问 我在app.js中有这个 /*** EXT LOADER ENABLE & PATH ***/ Ext.Loader.setConfig( { enabled : true, application : 'MyApp' }); Ext.log('--- APPLICATION --- Loading Elasticsearch configuration

我对正确实现代码的最佳方法有疑问

我在app.js中有这个

/*** EXT LOADER ENABLE & PATH                       ***/
Ext.Loader.setConfig(
{
    enabled             : true,
    application         : 'MyApp'
});

Ext.log('--- APPLICATION --- Loading Elasticsearch configuration');
Ext.define('MyApp.configuration.elastic',
{
    singleton   : true,
    ...
    loadElasticConfiguration: function()
    {
        // ExtDirect or ajax call in order to set configuration
    }
});
MyApp.configuration.elastic.loadElasticConfiguration();

Ext.onReady(function()
{});

Ext.create('MyApp.Application');
这是工作得很好,但我不喜欢有很多代码是app.js。 有没有办法将“MyApp.configuration.elastic”代码“导出”到特定文件并调用它。我已经尝试通过Ext.require,但其他需要此配置的文件在

如果有人有线索的话

祝你有愉快的一天

如果要使用,需要在侦听器中创建应用程序:

Ext.require('MyApp.configuration.elastic');

Ext.onReady(function(){
    Ext.create('MyApp.Application');
});
或者,这也应该起作用,因为它将使应用程序的主类需要config类:

Ext.define('MyApp.Application', {
    requires: ['MyApp.configuration.elastic'],
    // ...
});

我真是个白痴。当然,我可以这样做。我是为其他人做的谢谢,我为这个新手问题道歉。