Class CancelablePromise<T>

Cancelable promises extend base promises and provide a cancel functionality than can be used to cancel the execution or task of the promise.

These type of promises can be used to prevent additional processing when the data is not longer required (e.g. HTTP request for data that is not longer necessary)

Type Parameters

  • T

Hierarchy

  • CancelablePromise

Constructors

  • Type Parameters

    • T

    Parameters

    • executor: ((resolve: ((value: T | PromiseLike<T>) => void), reject: ((reason?: any) => void)) => void)
        • (resolve: ((value: T | PromiseLike<T>) => void), reject: ((reason?: any) => void)): void
        • Parameters

          • resolve: ((value: T | PromiseLike<T>) => void)
              • (value: T | PromiseLike<T>): void
              • Parameters

                • value: T | PromiseLike<T>

                Returns void

          • reject: ((reason?: any) => void)
              • (reason?: any): void
              • Parameters

                • Optional reason: any

                Returns void

          Returns void

    Returns CancelablePromise<T>

Properties

called: boolean = false

Flag set true when the resolve or reject method are called.

fulfilled: boolean = false

Flag to indicate if the promise has been fulfilled.

Promise has ben fulfilled when value/error is set.

onCancel: (() => void)

Type declaration

    • (): void
    • Returns void

onReject: ((error: any) => void)

Type declaration

    • (error: any): void
    • Parameters

      • error: any

      Returns void

onResolve: ((value: any) => void)

Type declaration

    • (value: any): void
    • Parameters

      • value: any

      Returns void

rejected: boolean = false

Flag to indicate if the promise was rejected.

Only set when the promise is fulfilled.

value: T

Output value of the promise.

Set with the output value if promise was fulfilled and not rejected.

Stores the error value if the promise was rejected.

Methods

  • Request to cancel the promise execution.

    Returns

    True if the promise is canceled successfully, false otherwise.

    Returns boolean

Generated using TypeDoc