The TaskExecutor is a task execution list, tasks can be added and will be executed one after another. Implementation hint: Pushed task are queued and executed as micro tasks in the next event queue slot.

import TaskExecutor from "apprt-core/TaskExecutor";
const executor = new TaskExecutor();
const task = function(){ doSomething(); };
// execute the task as fast as possible
executor.push(task);
// add again (will drop the old add, as long as the task was not executed)
executor.push(task);

Accessors

Methods

Accessors

  • get length(): number
  • Number of waiting tasks.

    Returns number

Methods

  • Add a task to the executor. If the task is already queued then the old is removed. A custom `task.equals' method can modify the behavior.

    Parameters

    • task: Task

      the task to execute.

    Returns void

  • Removes task from the list. The task.equals method can customize which tasks are removed.

    Parameters

    • task: Partial<Task> | () => void

      the task to remove

    Returns void