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

BaseStrategy.md

83 lines1.6 KB

1---
2id: BaseStrategy
3title: BaseStrategy
4---
5​
6# Interface: BaseStrategy\<TName\>
7​
8Defined in: [packages/db/src/strategies/types.ts:6](https://github.com/TanStack/db/blob/main/packages/db/src/strategies/types.ts#L6)
9​
10Base strategy interface that all strategy implementations must conform to
11​
12## Extended by
13​
14- [`DebounceStrategy`](DebounceStrategy.md)
15- [`QueueStrategy`](QueueStrategy.md)
16- [`ThrottleStrategy`](ThrottleStrategy.md)
17​
18## Type Parameters
19​
20### TName
21​
22`TName` *extends* `string` = `string`
23​
24## Properties
25​
26### \_type
27​
28```ts
29_type: TName;
30```
31​
32Defined in: [packages/db/src/strategies/types.ts:8](https://github.com/TanStack/db/blob/main/packages/db/src/strategies/types.ts#L8)
33​
34Type discriminator for strategy identification
35​
36***
37​
38### cleanup()
39​
40```ts
41cleanup: () => void;
42```
43​
44Defined in: [packages/db/src/strategies/types.ts:23](https://github.com/TanStack/db/blob/main/packages/db/src/strategies/types.ts#L23)
45​
46Clean up any resources held by the strategy
47Should be called when the strategy is no longer needed
48​
49#### Returns
50​
51`void`
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)