mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-29 21:09:56 +00:00
28 lines
1.6 KiB
Plaintext
28 lines
1.6 KiB
Plaintext
chapter.of: TiddlyWiki Core Application
|
|
created: 20140708084217106
|
|
modified: 20140717180507412
|
|
sub.num: 1
|
|
tags: doc
|
|
title: Startup Process
|
|
|
|
Modules with ``module-type: startup`` have to export a function named ``startup`` and may export a name property to identify this module. The startup function will be executed by the boot kernel at the end of the boot process.
|
|
|
|
```js
|
|
// From boot.js:
|
|
// Gather up any startup modules
|
|
$tw.boot.remainingStartupModules = []; // Array of startup modules
|
|
$tw.modules.forEachModuleOfType("startup",function(title,module) {
|
|
if(module.startup) {
|
|
$tw.boot.remainingStartupModules.push(module);
|
|
}
|
|
});
|
|
// Keep track of the startup tasks that have been executed
|
|
$tw.boot.executedStartupModules = Object.create(null);
|
|
$tw.boot.disabledStartupModules = $tw.boot.disabledStartupModules || [];
|
|
// Repeatedly execute the next eligible task
|
|
$tw.boot.executeNextStartupTask();
|
|
```
|
|
|
|
``executeNextStartupTask()`` will execute the remaining startup modules in ``remainingStartupModules``. A startup module can export the variables ``before`` and/or ``after``, each containing an array of names of other startup modules. ``executeNextStartupTask()`` will use this information to execute the modules in the correct order.
|
|
|
|
Startup modules can be marked as synchronous by exporting ``synchronous = true``. If synchronous is set to false, the startup function is executed with an callback function as the first argument. The startup function has to call this function to allow subsequent startup modules to get executed. This is necessary when the startup function itself uses asynchronous calls. |