Skip to content

About

JavaScript library to manage and control backgroud tasks via window.setTimeout or window.requestAnimationFrame

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

40 Commits

Folders and files

Repository files navigation

TaskManager

JavaScript library to manage and control backgroud tasks via window.setTimeout or window.requestAnimationFrame

Usage

Include into your website as JavaScript source

<script src="./TaskManager.js" type="text/javascript"></script>

API reference

  • invokeTask(function, priority = 0, name = null, doCheckTask = true): string
    Invokes the void function with given number priority (less is better).
    Name is optional
    doCheckTask disables invoking the check of queued tasks after insert.
    Returns the name of the generated repeated Task

  • run(function, name = null): string
    Alias for invokeTask, without optional parameters .
    Returns the name of the generated repeated Task

  • invokeScheduledTask(function, delay, priority = 0, name = null, doCheckTask = true): string
    Similar to invokeTask. The delay parameter gives the milliseconds timeout until the task is run.
    Returns the name of the generated repeated Task

  • setTimeout(function, delay, name = null): string
    Alias for invokeScheduledTask, without optional parameters .
    Returns the name of the generated repeated Task

  • invokeRepeatedTask(func, delay, zeroTimeRun = true, priority = 0, name = null, doCheckTask = true): string
    Repeats calling function every delay milliseconds.
    zeroTimeRun Boolean switch do invoke first iteration immediately.
    Returns the name of the generated repeated Task

  • setInterval(function, delay, zeroTimeRun = false, name = null): string
    Alias for invokeRepeatedTask, 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 for removeScheduledTask

  • removeRepeatedTask(name: string)
    Remves the repeated task from queue.
    Alias for removeScheduledTask

  • clearInterval(name: string)
    Alias for removeRepeatedTask

  • 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 if setUseAnimationFrame was set to true
    Default: 24 ms.

  • setUseAnimationFrame(value = false)
    Uses window.requestAnimationFrame instead of windows.setTimeout.
    setCheckTaskDelay will 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

Example

Just look at index.html

About

JavaScript library to manage and control backgroud tasks via window.setTimeout or window.requestAnimationFrame

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages