js/core/ModuleLoader.js
function (moduleName, moduleInstance, callback, routeContext, cachedInstance) {

                var self = this;

                //noinspection JSValidateTypes
                flow()
                    .seq(function (cb) {

                        self.$moduleInstance = moduleInstance;

                        var currentModule = self.$.currentModule;
                        if (currentModule) {
                            currentModule._unload(cb);
                        } else {
                            cb();
                        }
                    })
                    .seq(function (cb) {

                        // start module
                        moduleInstance.start(function (err) {

                            if (err || cachedInstance) {
                                cb(err);
                            } else {
                                if (routeContext) {
                                    // fresh instance with maybe new routers -> exec routes for new router
                                    var routeExecutionStack = [];

                                    for (var i = 0; i < moduleInstance.$routers.length; i++) {
                                        var router = moduleInstance.$routers[i];

                                        router.set("module", moduleInstance);

                                        routeExecutionStack = routeExecutionStack.concat(router.generateRoutingStack(routeContext.fragment));
                                    }

                                    flow()
                                        .seqEach(routeExecutionStack, function (routingFunction, cb) {
                                            routingFunction(cb);
                                        })
                                        .exec(cb);

                                } else {
                                    cb();
                                }

                            }
                        }, routeContext);
                    })
                    .seq(function () {
                        if (moduleInstance === self.$moduleInstance) {
                            self._clearContentPlaceHolders();

                            self.set('currentModuleName', moduleName);
                            var contentPlaceHolders = self.getContentPlaceHolders("external");

                            // set content
                            for (var i = 0; i < contentPlaceHolders.length; i++) {
                                var contentPlaceHolder = contentPlaceHolders[i];
                                contentPlaceHolder.set("content", moduleInstance.findContent(contentPlaceHolder.$.name));
                            }
                        }

                    })
                    .exec(function (err) {
                        var moduleInstance = self.$moduleInstance;

                        self.set({
                            state: err ? 'error' : null,
                            currentModule: moduleInstance
                        });

                        self.$moduleInstance = null;

                        if (callback) {
                            callback(err, moduleInstance);
                        }
                    });


            }
function (moduleName, moduleInstance, callback, routeContext, cachedInstance) {

                var self = this;

                //noinspection JSValidateTypes
                flow()
                    .seq(function (cb) {

                        self.$moduleInstance = moduleInstance;

                        var currentModule = self.$.currentModule;
                        if (currentModule) {
                            currentModule._unload(cb);
                        } else {
                            cb();
                        }
                    })
                    .seq(function (cb) {

                        // start module
                        moduleInstance.start(function (err) {

                            if (err || cachedInstance) {
                                cb(err);
                            } else {
                                if (routeContext) {
                                    // fresh instance with maybe new routers -> exec routes for new router
                                    var routeExecutionStack = [];

                                    for (var i = 0; i < moduleInstance.$routers.length; i++) {
                                        var router = moduleInstance.$routers[i];

                                        router.set("module", moduleInstance);

                                        routeExecutionStack = routeExecutionStack.concat(router.generateRoutingStack(routeContext.fragment));
                                    }

                                    flow()
                                        .seqEach(routeExecutionStack, function (routingFunction, cb) {
                                            routingFunction(cb);
                                        })
                                        .exec(cb);

                                } else {
                                    cb();
                                }

                            }
                        }, routeContext);
                    })
                    .seq(function () {
                        if (moduleInstance === self.$moduleInstance) {
                            self._clearContentPlaceHolders();

                            self.set('currentModuleName', moduleName);
                            var contentPlaceHolders = self.getContentPlaceHolders("external");

                            // set content
                            for (var i = 0; i < contentPlaceHolders.length; i++) {
                                var contentPlaceHolder = contentPlaceHolders[i];
                                contentPlaceHolder.set("content", moduleInstance.findContent(contentPlaceHolder.$.name));
                            }
                        }

                    })
                    .exec(function (err) {
                        var moduleInstance = self.$moduleInstance;

                        self.set({
                            state: err ? 'error' : null,
                            currentModule: moduleInstance
                        });

                        self.$moduleInstance = null;

                        if (callback) {
                            callback(err, moduleInstance);
                        }
                    });


            }
function ( moduleName , moduleInstance , callback , routeContext , cachedInstance ) { var self = this ; //noinspection JSValidateTypes flow ( ) . seq ( function ( cb ) { self . $moduleInstance = moduleInstance ; var currentModule = self . $ . currentModule ; if ( currentModule ) { currentModule . _unload ( cb ) ; } else { cb ( ) ; } } ) . seq ( function ( cb ) { // start module moduleInstance . start ( function ( err ) { if ( err || cachedInstance ) { cb ( err ) ; } else { if ( routeContext ) { // fresh instance with maybe new routers -> exec routes for new router var routeExecutionStack = [ ] ; for ( var i = 0 ; i < moduleInstance . $routers . length ; i ++ ) { var router = moduleInstance . $routers [ i ] ; router . set ( "module" , moduleInstance ) ; routeExecutionStack = routeExecutionStack . concat ( router . generateRoutingStack ( routeContext . fragment ) ) ; } flow ( ) . seqEach ( routeExecutionStack , function ( routingFunction , cb ) { routingFunction ( cb ) ; } ) . exec ( cb ) ; } else { cb ( ) ; } } } , routeContext ) ; } ) . seq ( function ( ) { if ( moduleInstance === self . $moduleInstance ) { self . _clearContentPlaceHolders ( ) ; self . set ( 'currentModuleName' , moduleName ) ; var contentPlaceHolders = self . getContentPlaceHolders ( "external" ) ; // set content for ( var i = 0 ; i < contentPlaceHolders . length ; i ++ ) { var contentPlaceHolder = contentPlaceHolders [ i ] ; contentPlaceHolder . set ( "content" , moduleInstance . findContent ( contentPlaceHolder . $ . name ) ) ; } } } ) . exec ( function ( err ) { var moduleInstance = self . $moduleInstance ; self . set ( { state : err ? 'error' : null , currentModule : moduleInstance } ) ; self . $moduleInstance = null ; if ( callback ) { callback ( err , moduleInstance ) ; } } ) ; }
Starts the module with the given name
@param {String} moduleName - The name of the module
@param {js.core.Module} moduleInstance - the module instance
@param {Function} callback - the callback function
@param {Object} routeContext - the route context
@param {Object} [cachedInstance]
@private
Starts the module with the given name