JavaScript library to manage and control backgroud tasks via window.setTimeout or window.requestAnimationFrame
<script src="./TaskManager.js" type="text/javascript"></script>
-
invokeTask(function, priority = 0, name = null, doCheckTask = true): string
Invokes the voidfunctionwith given numberpriority(less is better).
Nameis optional
doCheckTaskdisables invoking the check of queued tasks after insert.
Returns the name of the generated repeated Task -
run(function, name = null): string
Alias forinvokeTask, without optional parameters .
Returns the name of the generated repeated Task -
invokeScheduledTask(function, delay, priority = 0, name = null, doCheckTask = true): string
Similar toinvokeTask. Thedelayparameter gives the milliseconds timeout until the task is run.
Returns the name of the generated repeated Task -
setTimeout(function, delay, name = null): string
Alias forinvokeScheduledTask, without optional parameters .
Returns the name of the generated repeated Task -
invokeRepeatedTask(func, delay, zeroTimeRun = true, priority = 0, name = null, doCheckTask = true): string
Repeats callingfunctioneverydelaymilliseconds.
zeroTimeRunBoolean switch do invoke first iteration immediately.
Returns the name of the generated repeated Task -
setInterval(function, delay, zeroTimeRun = false, name = null): string
Alias forinvokeRepeatedTask, without optional parameters.
Returns the name of the generated repeated Task -
removeScheduledTask(name: string)
Removes the scheduled task from the queue. -
clearTimeout(name: string)
Alias forremoveScheduledTask -
removeRepeatedTask(name: string)
Remves the repeated task from queue.
Alias forremoveScheduledTask -
clearInterval(name: string)
Alias forremoveRepeatedTask -
getTaskList()
Returns list of tasks that will be run on next task check iteration -
getScheduledTaskList()
Returns list of scheduled tasks that are waiting to be executed -
setBatchSize(size = 3)
Sets the count of task that are executed by one check iteration.
Default: 3 -
setCheckTaskDelay(delay = 24)
Sets the timeout in milliseconds delay between next task check.
Will throw error ifsetUseAnimationFramewas set totrue
Default: 24 ms. -
setUseAnimationFrame(value = false)
Useswindow.requestAnimationFrameinstead of windows.setTimeout.
setCheckTaskDelaywill throw error if its called.
Default: false -
setOnTaskQueued(function)
Sets the monitor function(task, index)=>void, that is triggered when task was queued into the list -
setOnScheduledTaskQueued(function)
Sets the monitor function(task, index)=>void, that is triggered when task was queued into the scheduled list -
setOnTaskStart(function)
Sets the monitor function(task)=>void, that is triggered when task is dequeued from list and invoked -
setOnTaskEnd(function)
Sets the monitor function(task)=>void, that is triggered when task execuion ended
Just look at
index.html