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

BaseStrategy.md

81 lines1.6 KB

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