TanStack
API Reference

TimeoutProvider

ts
type TimeoutProvider<TTimerId> = object;

Defined in: packages/query-core/src/timeoutManager.ts:28

Backend for timer functions.

Timers are performance-sensitive: short-lived timers (delays under a few seconds) tend to be latency-sensitive, while long-lived ones may benefit more from coalescing — batching timers with similar deadlines together — which the default provider (backed by the platform's global setTimeout/setInterval) does not do. A custom provider can implement coalescing, and can also support delays longer than the ~24-day maximum of the global setTimeout.

Type Parameters

TTimerId

TTimerId extends ManagedTimerId = ManagedTimerId

Properties

PropertyModifierTypeDescription
clearIntervalreadonly(intervalId: TTimerId | undefined) => voidCancels an interval scheduled with setInterval.
clearTimeoutreadonly(timeoutId: TTimerId | undefined) => voidCancels a timeout scheduled with setTimeout.
setIntervalreadonly(callback: TimeoutCallback, delay: number) => TTimerIdSchedules callback to run every delay milliseconds, like the global setInterval.
setTimeoutreadonly(callback: TimeoutCallback, delay: number) => TTimerIdSchedules callback to run once after delay milliseconds, like the global setTimeout.