import type { AccessorOptions } from '../hooks/types'; export type Status = { isFetching: boolean; error: E | null; }; export type ModelSubscribe = (listener: () => void) => () => void; type RetryTimeoutMeta = { timeoutId: number; reject: () => void; }; export declare abstract class Accessor { protected status: Status; protected statusListeners: ((prev: Status, current: Status) => void)[]; protected fetchPromise: Promise; private retryTimeoutMeta; private startAt; private modelSubscribe; private optionsRefSet; private removeOnFocusListener; private removeOnReconnectListener; private pollingTimeoutId; /** * Whether the data, for which the accessor is responsible for fetching, is stale. */ private isStale; /** * Return the result of the revalidation. It may be `null` if the revalidation is aborted or encounters an error. */ abstract revalidate: () => Promise | null; /** * Get the state of the corresponding model. */ getState: (serverStateKey?: object) => S; /** * Get whether this accessor is stale or not. */ getIsStale: () => boolean; /** * Set the accessor to be stale. */ setIsStale: (isStale: boolean) => void; protected updateStatus: (partialStatus: Partial>) => void; protected notifyStatusListeners: (newCache: Status) => void; protected getOptions: () => Required; protected getRetryCount: () => number; protected getDedupeInterval: () => number; protected getRetryInterval: () => number; protected canFetch({ startAt }: { startAt: number; }): boolean; protected shouldDedupe(time: number): boolean; protected updateStartAt(time: number): void; protected isExpiredFetching(time: number): boolean; protected setRetryTimeoutMeta(meta: RetryTimeoutMeta): void; /** * Call this method before fetching start. * This method would: * - clear the polling timeout * - abort the error retry * - update the `fetchPromise` * - update the `startAt` * - update the status with `{ isFetching: true }` */ protected onFetchingStart: ({ fetchPromise, startAt, }: { fetchPromise: Promise; startAt: number; }) => void; protected onFetchingSuccess: () => void; private getFirstOptionsRef; private registerOnFocus; private registerOnReconnect; /** * invoke `this.revalidate` if `options.pollingInterval` is larger than 0. * @returns */ private invokePollingRevalidation; /** * Reject the current error retry and clear the error retry timeout. */ private abortRetry; /** * Determine whether this accessor is mounted by check whether there is an options ref. */ private isMounted; } export {};