Skip to content

debounce

function debounce(timeMs): RateLimit;

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

Debounce: wait until timeMs of quiet has elapsed before committing. Use it as the limitUrlUpdates option, e.g. for a search box that should only write the URL once the user stops typing.

Parameter Type
timeMs number

RateLimit

import { debounce, parseAsString, useQueryState } from "@xtandard/lib/tanstack";
debounce(300); // → { method: "debounce", timeMs: 300 }
const [q, setQ] = useQueryState("q", parseAsString.withDefault(""));
// In the input's onChange: state updates now, the URL 300 ms after the last keystroke.
void setQ(event.target.value, { limitUrlUpdates: debounce(300) });