Class: BaseModule

BaseModule

new BaseModule()

BaseModule is a class skeleton which helps you to build a module with

  • Centralized event handler
  • Centralized settings observation
  • Sub modules management including loading and starting
  • Import preload files
  • DOM rendering
  • Consistent logging function with System boot time and module name
  • Common publishing interface
.

BaseModule is a class skeleton which helps you to build a module with

  • Centralized event handler
  • Centralized settings observation
  • Sub modules management including loading and starting
  • Import preload files
  • DOM rendering
  • Consistent logging function with System boot time and module name
  • Common publishing interface
Source:

Methods

start()

The starting progress of a module has these steps:

  • import javascript files
  • lazy load submodules and instantiate once loaded.

The starting progress of a module has these steps:

  • import javascript files
  • lazy load submodules and instantiate once loaded.
  • custom start function
  • attach event listeners
  • observe settings
  • register services to System
  • DOM elements rendering (not implemented) The import is guranteed to happen before anything else. The service registration is expected to happen after everything is done. The ordering of the remaining parts should not depends each other.

The start function will return a promise to let you know when the module is started.

Source:
Example
var a = BaseModule.instantiate('A');
a.start().then(() => {
  console.log('started');
});

Note: a module start promise will only be resolved
after all the steps are resolved, including
the custom start promise and the promises from all the submodules.
So when you see a module is started, that means all of its
submodules are started as well.