A Promise that can be cancelled and provides progress/state tracking

interface CancellablePromise<T> {
    finally(onfinally?): Promise<T>;
    then<TResult1, TResult2>(onfulfilled?, onrejected?): Promise<TResult1 | TResult2>;
    catch<TResult>(onrejected?): Promise<T | TResult>;
    cancel(): Promise<void>;
    getController(): undefined | AbortController;
    isCancelled(): boolean;
    progress: number;
    status: string;
    isRunning: boolean;
    onProgressUpdate(callback): (() => void);
}

Type Parameters

  • T

Hierarchy

  • Promise<T>
    • CancellablePromise

Methods

  • 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: null | (() => void)

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

    Returns Promise<T>

    A Promise for the completion of the callback.

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

    Type Parameters

    • TResult1 = T
    • TResult2 = never

    Parameters

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

      The callback to execute when the Promise is resolved.

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

      The callback to execute when the Promise is rejected.

    Returns Promise<TResult1 | TResult2>

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

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

    Type Parameters

    • TResult = never

    Parameters

    • Optional onrejected: null | ((reason) => TResult | PromiseLike<TResult>)

      The callback to execute when the Promise is rejected.

    Returns Promise<T | TResult>

    A Promise for the completion of the callback.

  • Cancel this specific operation

    Returns Promise<void>

  • Get the underlying AbortController for this operation

    Returns undefined | AbortController

  • Check if this operation is cancelled

    Returns boolean

  • Subscribe to progress updates Returns a dispose function to clean up the subscription

    Parameters

    • callback: ((progress, status) => void)
        • (progress, status): void
        • Parameters

          • progress: number
          • status: string

          Returns void

    Returns (() => void)

      • (): void
      • Returns void

Properties

progress: number

Current progress of the operation (0-1)

status: string

Current status of the operation

isRunning: boolean

Whether the operation is currently running