Open History to see the last commit
1---
2id: throttleStrategy
3title: throttleStrategy
4---
5
6```ts
7function throttleStrategy(options): ThrottleStrategy;
8```
9
10Defined in: [packages/db/src/strategies/throttleStrategy.ts:49](https://github.com/TanStack/db/blob/main/packages/db/src/strategies/throttleStrategy.ts#L49)
11
12Creates a throttle strategy that ensures transactions are evenly spaced
13over time.
14
15Provides smooth, controlled execution patterns ideal for UI updates like
16sliders, progress bars, or scroll handlers where you want consistent
17execution timing.
18
19## Parameters
20
21### options
22
23[`ThrottleStrategyOptions`](../interfaces/ThrottleStrategyOptions.md)
24
25Configuration for throttle behavior
26
27## Returns
28
29[`ThrottleStrategy`](../interfaces/ThrottleStrategy.md)
30
31A throttle strategy instance
32
33## Examples
34
35```ts
36// Throttle slider updates to every 200ms
37const mutate = usePacedMutations({
38 onMutate: (volume) => {
39 settingsCollection.update('volume', draft => { draft.value = volume })
40 },
41 mutationFn: async ({ transaction }) => {
42 await api.updateVolume(transaction.mutations)
43 },
44 strategy: throttleStrategy({ wait: 200 })
45})
46```
47
48```ts
49// Throttle with leading and trailing execution
50const mutate = usePacedMutations({
51 onMutate: (data) => {
52 collection.update(id, draft => { Object.assign(draft, data) })
53 },
54 mutationFn: async ({ transaction }) => {
55 await api.save(transaction.mutations)
56 },
57 strategy: throttleStrategy({
58 wait: 500,
59 leading: true,
60 trailing: true
61 })
62})
63```