UNPKG

@legumeinfo/web-components

Version:

Web Components for the Legume Information System and other AgBio databases

64 lines 2.1 kB
import { ReactiveController, ReactiveControllerHost } from 'lit'; /** * A controller that allows Promises to be cancelled. * * Note that all Promises made cancellable with this controller are cancelled * with the same AbortSignal. Multiple instances of the controller should be * used if multiple signals are desired. */ export declare class LisCancelPromiseController implements ReactiveController { /** @ignore */ host: ReactiveControllerHost; /** @ignore */ private _abortController; /** * The abort signal that will cause the wrapped promises to cancel. This * signal can be used externally. */ abortSignal: AbortSignal; /** @ignore */ private _cancelState; /** @ignore */ private _listeners; /** * @param host - The component that's using the controller. */ constructor(host: ReactiveControllerHost); /** @ignore */ hostConnected(): void; /** @ignore */ hostDisconnected(): void; /** * Makes a Promise cancellable by racing it against a Promise that only * cancels. * * @typeParam T - The type of the value the {@link !Promise | `Promise`} to be * wrapped resolves to. * * @param promise - The promise to wrap. * * @returns A new {@link !Promise | `Promise`} that will resolve if the * `promise` parameter resolves or reject with the `'abort'` * {@link !Event | `Event`} raised by the * {@link LisCancelPromiseController.abortSignal | `abortSignal`} if the * promise is cancelled. */ wrapPromise<T>(promise: Promise<T>): Promise<T>; /** * Adds a listener to the abort event. * * @param listener - The listener to subscribe to cancel events. */ addListener(listener: EventListener): void; /** * Cancels all Promises that have been made since the last cancel. */ cancel(): void; /** @ignore */ private _addEventListener; /** @ignore */ private _initialize; /** @ignore */ private _aborted; } //# sourceMappingURL=lis-cancel-promise-controller.d.ts.map