Confirmed users
401
edits
| (6 intermediate revisions by the same user not shown) | |||
| Line 34: | Line 34: | ||
=== If the parent module is based on BaseModule === | === If the parent module is based on BaseModule === | ||
# Put the module in the parent module's SUB_MODULES if you think it's blocking the starting progress of the parent module. | |||
# If the new module is not as important to block the parent, use this.loadWhenIdle([NEW_MODULE]) in parent's start function | |||
# If the new module is only serving some on demand request, consider to lazy load the new module in the parent module's event handler and start it. | |||
=== If the parent module is not based on BaseModule === | === If the parent module is not based on BaseModule === | ||
# Lazy load the module in the parent module's start function and return a promise including the promise of the lazy loader | |||
# If the new module is only serving some on demand request, consider to lazy load the new module in the parent module's event handler and start it. | |||
== Samples == | == Samples == | ||
| Line 44: | Line 46: | ||
1. Core is an existing module who blocks the first view | 1. Core is an existing module who blocks the first view | ||
2. ParentModule is an existing module who does not block the first view | 2. ParentModule is an existing module who does not block the first view | ||
=== Sample for the module which does block the first view === | === Sample for the module which does block the first view and the parent module is a base module === | ||
// ftu_loader.js | // ftu_loader.js | ||
var FtuLoader = function() {}; | var FtuLoader = function() {}; | ||
| Line 72: | Line 74: | ||
// core.js | // core.js | ||
Core | BaseModule.create(Core, { | ||
_start = function() { | |||
}; | return this.loadWhenIdle(['SideTester']); | ||
}; | |||
}); | |||
=== Sample for the new module which does not block the first view and the parent is not a baseModule === | === Sample for the new module which does not block the first view and the parent is not a baseModule === | ||
| Line 81: | Line 85: | ||
ChildModule.prototype.start = function() {}; | ChildModule.prototype.start = function() {}; | ||
// | // parent_module.js | ||
ParentModule.prototype.start = function() { | ParentModule.prototype.start = function() { | ||
return Service.request('schedule', () => { // This is exactly what BaseModule.prototype.loadWhenIdle does | return Service.request('schedule', () => { // This is exactly what BaseModule.prototype.loadWhenIdle does | ||