solid-awesome-hooks
Version:
A collection of awesome hooks for solid-js
31 lines (30 loc) • 1.1 kB
TypeScript
import { type Accessor, type Owner } from "solid-js";
type UsePollingOptions = {
/**
* Time interval to call "poll" function
* @default 3000
*/
timeInterval?: number;
enabled?: Accessor<boolean>;
/**
* The maximum number of function calls
* When request count exceeds this limit, polling stops
* Pass Infinity to avoid this behavior if necessary
* @default 10
*/
callLimit?: number;
/**
* This hook uses setTimeout for polling, so it might be the case when `poll` function triggers reactive things.
* To make it work correctly pass proper owner for the `poll` function.
* Otherwise it will be assigned automatically (the owner of the hook will be used)
*/
owner?: Owner | null;
};
/**
*
* @param readyTrigger Reactive signal that tells that the poll function can now be scheduled
* @param poll Function
* @param options {UsePollingOptions}
*/
export declare const usePolling: (readyTrigger: Accessor<unknown>, poll: VoidFunction, options?: UsePollingOptions) => void;
export {};