CancelToken Class

    Package: @esfx/canceltoken

    Propagates notifications that operations should be canceled.

    Declaration
    export declare class CancelToken implements Cancelable, CancelSignal 

    Properties

    [kEventTarget]

    Declaration
    static [kEventTarget]: boolean;
    Property Value
    boolean

    canBeSignaled

    Gets a value indicating whether the token can be signaled.

    Declaration
    get canBeSignaled(): boolean;
    Property Value
    boolean

    canceled

    Declaration
    static readonly canceled: CancelToken;
    Property Value
    CancelToken

    none

    Declaration
    static readonly none: CancelToken;
    Property Value
    CancelToken

    reason

    Gets the reason for cancellation.

    Declaration
    get reason(): unknown;
    Property Value
    unknown

    signaled

    Gets a value indicating whether the token is signaled.

    Declaration
    get signaled(): boolean;
    Property Value
    boolean

    Methods

    [Cancelable.cancelSignal]()

    Gets the CancelSignal for this Cancelable.

    Declaration
    [Cancelable.cancelSignal](): CancelToken;
    Returns
    CancelToken

    all(cancelables)

    Returns a CancelToken that becomes signaled when all of the provided cancelables are signaled.

    Declaration
    static all(cancelables: Iterable<Cancelable | DOMAbortSignal | null | undefined>): CancelToken;
    Parameters
    cancelables
    Iterable<Cancelable | DOMAbortSignal | null | undefined>

    An iterable of Cancelable objects.

    Returns
    CancelToken

    canceledWith(reason)

    Gets a CancelToken that is already canceled with the provided reason.

    Declaration
    static canceledWith(reason: unknown): CancelToken;
    Parameters
    reason
    unknown

    Returns
    CancelToken

    from(cancelable)

    Adapts a CancelToken from a cancelable.

    Declaration
    static from(cancelable: Cancelable | DOMAbortSignal | null | undefined): CancelToken;
    Parameters
    cancelable
    Cancelable | DOMAbortSignal | null | undefined

    Returns
    CancelToken

    race(cancelables)

    Returns a CancelToken that becomes signaled when any of the provided cancelables are signaled.

    Declaration
    static race(cancelables: Iterable<Cancelable | DOMAbortSignal | null | undefined>): CancelToken;
    Parameters
    cancelables
    Iterable<Cancelable | DOMAbortSignal | null | undefined>

    An iterable of Cancelable objects.

    Returns
    CancelToken

    Remarks

    This is similar to calling source(cancelables) with the provided cancelables. In general, calling source(cancelables) is preferred as it provides better resource management.

    source(cancelables)

    Creates a new CancelSource.

    Declaration
    static source(cancelables?: Iterable<Cancelable | DOMAbortSignal | null | undefined>): CancelSource;
    Parameters
    cancelables
    Iterable<Cancelable | DOMAbortSignal | null | undefined>

    An optional iterable of Cancelable objects. If present, the source becomes linked to the provided cancelables and will be canceled when a linked cancelable is canceled.

    Returns
    CancelSource

    Remarks

    Calling source(cancelables) with cancelables is similar to race(cancelables), except you can individually cancel or close the resulting source. This can be better for memory or GC purposes, since when the resulting source is canceled or closed it can be unlinked from the cancelables, removing references from each cancelable to the resulting source which could otherwise prevent garbage collection.

    subscribe(onSignaled)

    Subscribes to notifications for when the object becomes signaled.

    Declaration
    subscribe(onSignaled: () => void): CancelSubscription;
    Parameters
    onSignaled
    () => void

    Returns
    CancelSubscription

    throwIfSignaled()

    Throws a CancelError if the token was signaled.

    Declaration
    throwIfSignaled(): void;
    Returns
    void

    timeout(ms, reason)

    Gets a CancelToken that will be canceled with the provided reason after a timeout has elapsed.

    Declaration
    static timeout(ms: number, reason?: unknown): CancelToken;
    Parameters
    ms
    number

    reason
    unknown

    Returns
    CancelToken

    Generated by DocFX