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

QueuerOptions.md

295 lines4.7 KB

1---
2id: QueuerOptions
3title: QueuerOptions
4---
5​
6Defined in: [queuer.ts:83](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L83)
7​
8Options for configuring a Queuer instance.
9​
10These options control queue behavior, item expiration, callbacks, and more.
11​
12## Type Parameters
13​
14### TValue
15​
16`TValue`
17​
18## Properties
19​
20### addItemsTo?
21​
22```ts
23optional addItemsTo?: QueuePosition;
24```
25​
26Defined in: [queuer.ts:88](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L88)
27​
28Default position to add items to the queuer
29​
30#### Default
31​
32```ts
33'back'
34```
35​
36***
37​
38### expirationDuration?
39​
40```ts
41optional expirationDuration?: number;
42```
43​
44Defined in: [queuer.ts:93](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L93)
45​
46Maximum time in milliseconds that an item can stay in the queue
47If not provided, items will never expire
48​
49***
50​
51### getIsExpired?
52​
53```ts
54optional getIsExpired?: (item, addedAt) => boolean;
55```
56​
57Defined in: [queuer.ts:98](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L98)
58​
59Function to determine if an item has expired
60If provided, this overrides the expirationDuration behavior
61​
62#### Parameters
63​
64##### item
65​
66`TValue`
67​
68##### addedAt
69​
70`number`
71​
72#### Returns
73​
74`boolean`
75​
76***
77​
78### getItemsFrom?
79​
80```ts
81optional getItemsFrom?: QueuePosition;
82```
83​
84Defined in: [queuer.ts:103](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L103)
85​
86Default position to get items from during processing
87​
88#### Default
89​
90```ts
91'front'
92```
93​
94***
95​
96### getPriority?
97​
98```ts
99optional getPriority?: (item) => number;
100```
101​
102Defined in: [queuer.ts:108](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L108)
103​
104Function to determine priority of items in the queuer
105Higher priority items will be processed first
106​
107#### Parameters
108​
109##### item
110​
111`TValue`
112​
113#### Returns
114​
115`number`
116​
117***
118​
119### initialItems?
120​
121```ts
122optional initialItems?: TValue[];
123```
124​
125Defined in: [queuer.ts:112](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L112)
126​
127Initial items to populate the queuer with
128​
129***
130​
131### initialState?
132​
133```ts
134optional initialState?: Partial<QueuerState<TValue>>;
135```
136​
137Defined in: [queuer.ts:116](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L116)
138​
139Initial state for the queuer
140​
141***
142​
143### key?
144​
145```ts
146optional key?: string;
147```
148​
149Defined in: [queuer.ts:121](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L121)
150​
151Optional key to identify this queuer instance.
152If provided, the queuer will be identified by this key in the devtools and PacerProvider if applicable.
153​
154***
155​
156### maxSize?
157​
158```ts
159optional maxSize?: number;
160```
161​
162Defined in: [queuer.ts:125](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L125)
163​
164Maximum number of items allowed in the queuer
165​
166***
167​
168### onExecute?
169​
170```ts
171optional onExecute?: (item, queuer) => void;
172```
173​
174Defined in: [queuer.ts:129](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L129)
175​
176Callback fired whenever an item is removed from the queuer
177​
178#### Parameters
179​
180##### item
181​
182`TValue`
183​
184##### queuer
185​
186[`Queuer`](../classes/Queuer.md)\<`TValue`\>
187​
188#### Returns
189​
190`void`
191​
192***
193​
194### onExpire?
195​
196```ts
197optional onExpire?: (item, queuer) => void;
198```
199​
200Defined in: [queuer.ts:133](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L133)
201​
202Callback fired whenever an item expires in the queuer
203​
204#### Parameters
205​
206##### item
207​
208`TValue`
209​
210##### queuer
211​
212[`Queuer`](../classes/Queuer.md)\<`TValue`\>
213​
214#### Returns
215​
216`void`
217​
218***
219​
220### onItemsChange?
221​
222```ts
223optional onItemsChange?: (queuer) => void;
224```
225​
226Defined in: [queuer.ts:137](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L137)
227​
228Callback fired whenever an item is added or removed from the queuer
229​
230#### Parameters
231​
232##### queuer
233​
234[`Queuer`](../classes/Queuer.md)\<`TValue`\>
235​
236#### Returns
237​
238`void`
239​
240***
241​
242### onReject?
243​
244```ts
245optional onReject?: (item, queuer) => void;
246```
247​
248Defined in: [queuer.ts:141](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L141)
249​
250Callback fired whenever an item is rejected from being added to the queuer
251​
252#### Parameters
253​
254##### item
255​
256`TValue`
257​
258##### queuer
259​
260[`Queuer`](../classes/Queuer.md)\<`TValue`\>
261​
262#### Returns
263​
264`void`
265​
266***
267​
268### started?
269​
270```ts
271optional started?: boolean;
272```
273​
274Defined in: [queuer.ts:145](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L145)
275​
276Whether the queuer should start processing tasks immediately
277​
278***
279​
280### wait?
281​
282```ts
283optional wait?: number | ((queuer) => number);
284```
285​
286Defined in: [queuer.ts:151](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/queuer.ts#L151)
287​
288Time in milliseconds to wait between processing items.
289Can be a number or a function that returns a number.
290​
291#### Default
292​
293```ts
295```