Skip to content

throttle

function throttle(timeMs): RateLimit;

Defined in: tanstack/core/rate-limit.ts:31

Throttle: commit the first update quickly, then at most once per timeMs. Pass Infinity to keep state in sync while never committing to the URL. Use it as the limitUrlUpdates option.

Parameter Type
timeMs number

RateLimit

import { parseAsString, throttle, useQueryState } from "@xtandard/lib/tanstack";
throttle(120); // → { method: "throttle", timeMs: 120 }
// Slider: state follows the thumb, the URL updates at most every 120 ms.
const [q, setQ] = useQueryState(
"q",
parseAsString.withDefault("").withOptions({ limitUrlUpdates: throttle(120) }),
);