Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

ThrottleStrategy.md

95 lines1.9 KB

1---
2id: ThrottleStrategy
3title: ThrottleStrategy
4---
5​
6Defined in: [packages/db/src/strategies/types.ts:90](https://github.com/TanStack/db/blob/main/packages/db/src/strategies/types.ts#L90)
7​
8Throttle strategy that spaces executions evenly over time
9​
10## Extends
11​
12- [`BaseStrategy`](BaseStrategy.md)\<`"throttle"`\>
13​
14## Properties
15​
16### \_type
17​
18```ts
19_type: "throttle";
20```
21​
22Defined in: [packages/db/src/strategies/types.ts:8](https://github.com/TanStack/db/blob/main/packages/db/src/strategies/types.ts#L8)
23​
24Type discriminator for strategy identification
25​
26#### Inherited from
27​
28[`BaseStrategy`](BaseStrategy.md).[`_type`](BaseStrategy.md#_type)
29​
30***
31​
32### cleanup()
33​
34```ts
35cleanup: () => void;
36```
37​
38Defined in: [packages/db/src/strategies/types.ts:23](https://github.com/TanStack/db/blob/main/packages/db/src/strategies/types.ts#L23)
39​
40Clean up any resources held by the strategy
41Should be called when the strategy is no longer needed
42​
43#### Returns
44​
45`void`
46​
47#### Inherited from
48​
49[`BaseStrategy`](BaseStrategy.md).[`cleanup`](BaseStrategy.md#cleanup)
50​
51***
52​
53### execute()
54​
55```ts
56execute: <T>(fn) => boolean | void | Promise<void>;
57```
58​
59Defined in: [packages/db/src/strategies/types.ts:15](https://github.com/TanStack/db/blob/main/packages/db/src/strategies/types.ts#L15)
60​
61Execute a function according to the strategy's timing rules
62​
63#### Type Parameters
64​
65##### T
66​
67`T` *extends* `object` = `Record`\<`string`, `unknown`\>
68​
69#### Parameters
70​
71##### fn
72​
73() => [`Transaction`](Transaction.md)\<`T`\>
74​
75The function to execute
76​
77#### Returns
78​
79`boolean` \| `void` \| `Promise`\<`void`\>
80​
81The result of the function execution (if applicable)
82​
83#### Inherited from
84​
85[`BaseStrategy`](BaseStrategy.md).[`execute`](BaseStrategy.md#execute)
86​
87***
88​
89### options
90​
91```ts
92options: ThrottleStrategyOptions;
93```
94​
95Defined in: [packages/db/src/strategies/types.ts:91](https://github.com/TanStack/db/blob/main/packages/db/src/strategies/types.ts#L91)