Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Module structure in application

$
0
0
Hi, all.
Is there way to load js files in asynchronous manner? I want implement module structure in my application.
I know that there is FileLoader.loadJSFiles method. But I don't know how use it properly.
For example I have init.js
Code:

isc.FileLoader.loadJSFiles([ 'js/AAA.js' ], function() {
        console.info('create AAA')
        AAA.create();
});

and two component classes: AAA and BBB. Coponent AAA depends on component BBB.
AAA.js
Code:

isc.FileLoader.loadJSFiles([ 'js/BBB.js' ]);

console.info('define AAA');
isc.defineClass('AAA', 'HLayout').addProperties({
        initWidget : function() {

                console.info('create BBB');
                this.addMembers([ BBB.create() ])
        }
});

BBB.js
Code:

console.info('define BBB');
isc.defineClass('BBB', 'HLayout').addProperties({

});

Now, when I run this mini application I see following console output and error:
Code:

define AAA
create AAA
create BBB
ReferenceError: BBB is not defined
define BBB

I know why the error occur and I understand how it works.
But I don't know how avoid this error and implement asynchronous loading properly.

Viewing all articles
Browse latest Browse all 4756

Trending Articles