Class Task<ReturnValueType>

Task instance, created when you call the add, prepend, insertAt methods of Queue instance.

Remarks

Not exported and not intended to instantiate manually.

Type Parameters

  • ReturnValueType = unknown

Hierarchy

  • Task

Properties

data?: {
    [key: string]: unknown;
}

Data associated with this task, when added to the queue. Can be freely modified at any point.

Type declaration

  • [key: string]: unknown

Accessors

  • get promise(): Promise<ReturnValueType>
  • Gets you the promise which you can use to attach a .then and .catch callbacks if you are interested in result of your task.

    Remark

    You should actually always attach .catch callback to prevent UncaughtRejection errors from being thrown.

    Returns Promise<ReturnValueType>

Methods

  • Gets task position in the queue.

    Returns

    task index or -1 if not found in the queue

    Returns number

  • Gets task waiting position in the queue. 0 means the task is next one to be run. -1 means task is no longer waiting (running or done).

    Returns

    task wait index or -1 if not waiting

    Returns number

  • Checks if task was requested to be cancelled.

    Returns

    true if task was cancelled, false otherwise

    Returns boolean

  • Checks if task is currently running.

    Returns

    true if task is running, false otherwise

    Returns boolean

  • Removes task from list without cancelling it.

    Deprecated

    use cancel instead

    Returns void

  • Starts the task.

    Throws

    Error - when task is already started or task belongs to queue that is destroyed

    Returns

    A promise than resolves after task is resolved or rejected. This promise doesn't contain resolved value or rejected error, for this use promise

    Returns Promise<void>

Generated using TypeDoc