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

ThrottleStrategy.md

97 lines1.9 KB

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