1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-26 19:47:20 +00:00

Add support for "before" field on startup modules

This commit is contained in:
Jermolene 2014-05-03 19:49:50 +01:00
parent 5b5621a600
commit 09156af475
2 changed files with 16 additions and 4 deletions

View File

@ -1750,6 +1750,7 @@ $tw.boot.executeNextStartupTask = function() {
if($tw.boot.isStartupTaskEligible(task)) {
// Remove this task from the list
$tw.boot.remainingStartupModules.splice(taskIndex,1);
console.log("Executing task",task.name);
// Execute it
if(!$tw.utils.hop(task,"synchronous") || task.synchronous) {
task.startup();
@ -1783,6 +1784,16 @@ $tw.boot.isStartupTaskEligible = function(taskModule) {
}
}
}
// Check that no other outstanding tasks must be executed before this one
var name = taskModule.name,
remaining = $tw.boot.remainingStartupModules;
if(name) {
for(t=0; t<remaining.length; t++) {
if(remaining[t].before && remaining[t].before.indexOf(name) !== -1) {
return false;
}
}
}
// Check that all of the tasks that we must be performed after has been done
var after = taskModule.after;
if(after) {

View File

@ -10,11 +10,12 @@ The startup mechanism runs the installed startup modules at the end of the [[boo
Modules with their ''module-type'' field set to `startup`:
* Must expose a `startup` function
* Must export a `startup` function
** For synchronous startup modules the startup function is called as `startup()`, asynchronous modules are passed a callback they must invoke on completion: `startup(callback)`
* May expose a `name` property that is used to identify the task
* May expose a `after` property containing an array of names of dependent tasks that must be run before this one
* May expose a `platforms` property containing an array of names of platforms that are required in order for the startup module to be executed. The defined platforms are ''node'' and ''browser''
* May export a `name` property that is used to identify the task
* May export a `after` property containing an array of names of dependent tasks that must be run before this one
* May export a `before` property containing an array of names of tasks that must be run after this one
* May export a `platforms` property containing an array of names of platforms that are required in order for the startup module to be executed. The defined platforms are ''node'' and ''browser''
! Startup Processing