Promise like object but tracks promise state and has explicit start method looking more like a task class

Type Parameters

  • T extends ((...args) => Promise<R>)

  • R = any

Hierarchy

  • Task

Implements

Constructors

  • Type Parameters

    • T extends ((...args) => Promise<R>)

    • R = any

    Parameters

    • task: T
    • thisArg: any = null
    • Optional options: {
          bubbleExceptions?: boolean;
      }
      • Optional bubbleExceptions?: boolean

    Returns Task<T, R>

Properties

#hasError: boolean = false
#innerPromise?: Promise<R>
#isFinished: boolean = false
#isRunning: boolean = false
[toStringTag]: "Task" = 'Task'
options?: {
    bubbleExceptions?: boolean;
}

Type declaration

  • Optional bubbleExceptions?: boolean
task: T
thisArg: any = null

Accessors

Methods

  • Attaches a callback for only the rejection of the Promise.

    Type Parameters

    • TResult1

    Parameters

    • Optional onrejected: ((reason) => TResult1 | Promise<TResult1>)

      The callback to execute when the Promise is rejected.

        • (reason): TResult1 | Promise<TResult1>
        • Parameters

          • reason: any

          Returns TResult1 | Promise<TResult1>

    Returns Promise<R | TResult1>

    A Promise for the completion of the callback.

  • Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The resolved value cannot be modified from the callback.

    Parameters

    • Optional onfinally: (() => void)

      The callback to execute when the Promise is settled (fulfilled or rejected).

        • (): void
        • Returns void

    Returns Promise<R>

    A Promise for the completion of the callback.

  • Attaches callbacks for the resolution and/or rejection of the Promise.

    Type Parameters

    • TResult1

    • TResult2

    Parameters

    • Optional onfulfilled: ((value) => TResult1 | PromiseLike<TResult1>)

      The callback to execute when the Promise is resolved.

        • (value): TResult1 | PromiseLike<TResult1>
        • Parameters

          • value: R

          Returns TResult1 | PromiseLike<TResult1>

    • Optional onrejected: ((reason) => TResult2 | Promise<TResult2>)

      The callback to execute when the Promise is rejected.

        • (reason): TResult2 | Promise<TResult2>
        • Parameters

          • reason: any

          Returns TResult2 | Promise<TResult2>

    Returns Promise<TResult1 | TResult2>

    A Promise for the completion of which ever callback is executed.