@mirawision/reactive-hooks
Version:
A comprehensive collection of 50+ React hooks for state management, UI interactions, device APIs, async operations, drag & drop, audio/speech, and more. Full TypeScript support with SSR safety.
20 lines (19 loc) • 683 B
TypeScript
export interface PollingState<T> {
data: T | null;
error: any;
running: boolean;
start: () => void;
stop: () => void;
}
export interface PollingOptions {
immediate?: boolean;
pause?: boolean;
}
/**
* A hook that periodically executes an async function.
* @param fn The async function to execute periodically
* @param intervalMs The interval between executions in milliseconds
* @param opts Configuration options for polling behavior
* @returns PollingState object containing data, error, running state, and control functions
*/
export declare function usePolling<T>(fn: () => Promise<T>, intervalMs: number, opts?: PollingOptions): PollingState<T>;