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

QueueStrategy.md

101 lines2.0 KB

1---
2id: QueueStrategy
3title: QueueStrategy
4---
5​
6Defined in: [packages/db/src/strategies/types.ts:73](https://github.com/TanStack/db/blob/main/packages/db/src/strategies/types.ts#L73)
7​
8Queue strategy that processes all executions in order
9FIFO: { addItemsTo: 'back', getItemsFrom: 'front' }
10LIFO: { addItemsTo: 'back', getItemsFrom: 'back' }
11​
12## Extends
13​
14- [`BaseStrategy`](BaseStrategy.md)\<`"queue"`\>
15​
16## Properties
17​
18### \_type
19​
20```ts
21_type: "queue";
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:30](https://github.com/TanStack/db/blob/main/packages/db/src/strategies/types.ts#L30)
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, onAdmit?, onCommit?) => boolean | void | Promise<void>;
59```
60​
61Defined in: [packages/db/src/strategies/types.ts:76](https://github.com/TanStack/db/blob/main/packages/db/src/strategies/types.ts#L76)
62​
63Explicit false rejects the transaction; void preserves custom strategies.
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​
77##### onAdmit?
78​
79() => `void` \| [`Transaction`](Transaction.md)\<`T`\>
80​
81##### onCommit?
82​
83() => `Promise`\<`unknown`\> \| `undefined`
84​
85#### Returns
86​
87`boolean` \| `void` \| `Promise`\<`void`\>
88​
89#### Overrides
90​
91[`BaseStrategy`](BaseStrategy.md).[`execute`](BaseStrategy.md#execute)
92​
93***
94​
95### options?
96​
97```ts
98optional options: QueueStrategyOptions;
99```
100​
101Defined in: [packages/db/src/strategies/types.ts:74](https://github.com/TanStack/db/blob/main/packages/db/src/strategies/types.ts#L74)