Options
All
  • Public
  • Public/Protected
  • All
Menu

Default implementation of a task. Keeps the state of a state and allows to register handlers that are invoked in case of task completion or error.

Type parameters

  • T

Hierarchy

  • WorkerTask

Implements

Index

Constructors

constructor

Properties

definition

definition: ITaskDefinition

the definition of the operation to execute

isCanceled

isCanceled: boolean = false

isCancellationRequested

isCancellationRequested: boolean = false

Private promise

promise: Promise<T>

Private rejectPromise

rejectPromise: function

Type declaration

    • (error: any): void
    • Parameters

      • error: any

      Returns void

Private resolvePromise

resolvePromise: function

Type declaration

    • (result?: T): void
    • Parameters

      • Optional result: T

      Returns void

Methods

cancel

  • cancel(): void

catch

  • catch(onrejected: function): Promise<any>
  • Parameters

    • onrejected: function
        • (reason: any): any
        • Parameters

          • reason: any

          Returns any

    Returns Promise<any>

reject

  • reject(error: any): void
  • Marks the task as failed

    Parameters

    • error: any

      the error that occurred while processing the task

    Returns void

resolve

  • resolve(result: T): void
  • Marks the task as complete where the given value is the task result. Triggers all registered then handlers of the promise. However, if the task has been cancelled in the mean time, then the catch handlers are triggered instead

    Parameters

    • result: T

      the result of the task execution

    Returns void

resolveCancelled

  • resolveCancelled(): void

then

  • then<TResult>(onfulfilled: function, onrejected?: undefined | function): Promise<TResult>
  • Type parameters

    • TResult

    Parameters

    • onfulfilled: function
        • (value: T): TResult | PromiseLike<TResult>
        • Parameters

          • value: T

          Returns TResult | PromiseLike<TResult>

    • Optional onrejected: undefined | function

    Returns Promise<TResult>

Generated using TypeDoc