UNPKG

ahooks

Version:
20 lines (19 loc) 915 B
declare const CANCELLED_ERROR_FLAG = "__AHOOKS_CANCELLED_ERROR__"; interface PendingPromiseRef { current: ((reason?: unknown) => void) | undefined; } /** * Rejection reason used when `useRequest` ignores a request, either because * `cancel()` was called (or the component unmounted), or because a newer call superseded it. * * It is swallowed by `run`/`refresh`, by `options.onError` and by the plugin `onError` * handlers, so it only surfaces to code that awaits `runAsync`/`refreshAsync` directly. */ export declare class CancelledError extends Error { /** Marker that survives duplicated copies of the module, unlike `instanceof`. */ readonly [CANCELLED_ERROR_FLAG] = true; constructor(message?: string); } export declare function isCancelledError(error: unknown): error is CancelledError; export declare function cancelPendingPromise(pendingRejectRef: PendingPromiseRef): void; export {};