1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-09-20 03:09:42 +00:00
TiddlyWiki5/editions/dev/tiddlers/from Heigele and Jurke/Startup%20Process.tid
Jermolene 1a95ec9ac4 Introduce dev edition
Thanks to @cjrk and @cheigele for contributing their developer docs
(which can be found at https://github.com/cjrk/saa-tw).

By the way, I plan to remove the “creator” and “modifier” fields but
will keep a prominent acknowledgement for your contributions.
2014-09-10 16:53:32 +01:00

30 lines
1.7 KiB
Plaintext

chapter.of: TiddlyWiki Core Application
created: 20140708084217106
creator: Christian Heigele, Christian Jurke
modified: 20140717180507412
modifier: Christian Heigele, Christian Jurke
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.
```
// 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.