/** * Reactive polling composable for periodic data fetching. * * @module bquery/reactive */ import { type AsyncDataState, type FetchInput, type UseFetchOptions } from './async-data'; /** Options for usePolling(). */ export interface UsePollingOptions extends UseFetchOptions { /** Polling interval in milliseconds. */ interval: number; /** Whether polling is initially enabled (default: true). Can be a reactive getter. */ enabled?: boolean | (() => boolean); /** Pause polling when the document is hidden (default: true). */ pauseOnHidden?: boolean; /** Pause polling when the browser is offline (default: true). */ pauseOnOffline?: boolean; } /** Extended return value from usePolling(). */ export interface PollingState extends AsyncDataState { /** Pause polling. */ pause: () => void; /** Resume polling. */ resume: () => void; /** Reactive boolean indicating whether polling is currently active. */ isActive: { readonly value: boolean; peek(): boolean; }; } /** * Reactive polling composable that periodically fetches data. * * @template TResponse - Raw parsed response type * @template TData - Stored response type after optional transformation * @param input - Request URL, Request object, or lazy input factory * @param options - Polling and fetch options * @returns Extended fetch state with pause(), resume(), and isActive * * @example * ```ts * import { usePolling } from '@bquery/bquery/reactive'; * * const notifications = usePolling('/api/notifications', { * interval: 30_000, * pauseOnHidden: true, * pauseOnOffline: true, * }); * * // Manually pause/resume * notifications.pause(); * notifications.resume(); * ``` */ export declare const usePolling: (input: FetchInput, options: UsePollingOptions) => PollingState; //# sourceMappingURL=polling.d.ts.map