Open History to see the last commit
1---
2id: BatcherOptions
3title: BatcherOptions
4---
5
6Defined in: [batcher.ts:52](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L52)
7
8Options for configuring a Batcher instance
9
10## Type Parameters
11
12### TValue
13
14`TValue`
15
16## Properties
17
18### getShouldExecute?
19
20```ts
21optional getShouldExecute?: (items, batcher) => boolean;
22```
23
24Defined in: [batcher.ts:57](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L57)
25
26Custom function to determine if a batch should be processed
27Return true to process the batch immediately
28
29#### Parameters
30
31##### items
32
33`TValue`[]
34
35##### batcher
36
37[`Batcher`](../classes/Batcher.md)\<`TValue`\>
38
39#### Returns
40
41`boolean`
42
43***
44
45### initialState?
46
47```ts
48optional initialState?: Partial<BatcherState<TValue>>;
49```
50
51Defined in: [batcher.ts:61](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L61)
52
53Initial state for the batcher
54
55***
56
57### key?
58
59```ts
60optional key?: string;
61```
62
63Defined in: [batcher.ts:66](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L66)
64
65Optional key to identify this batcher instance.
66If provided, the batcher will be identified by this key in the devtools and PacerProvider if applicable.
67
68***
69
70### maxSize?
71
72```ts
73optional maxSize?: number;
74```
75
76Defined in: [batcher.ts:71](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L71)
77
78Maximum number of items in a batch
79
80#### Default
81
82```ts
83Infinity
84```
85
86***
87
88### onExecute?
89
90```ts
91optional onExecute?: (batch, batcher) => void;
92```
93
94Defined in: [batcher.ts:75](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L75)
95
96Callback fired after a batch is processed
97
98#### Parameters
99
100##### batch
101
102`TValue`[]
103
104##### batcher
105
106[`Batcher`](../classes/Batcher.md)\<`TValue`\>
107
108#### Returns
109
110`void`
111
112***
113
114### onItemsChange?
115
116```ts
117optional onItemsChange?: (batcher) => void;
118```
119
120Defined in: [batcher.ts:79](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L79)
121
122Callback fired after items are added to the batcher
123
124#### Parameters
125
126##### batcher
127
128[`Batcher`](../classes/Batcher.md)\<`TValue`\>
129
130#### Returns
131
132`void`
133
134***
135
136### started?
137
138```ts
139optional started?: boolean;
140```
141
142Defined in: [batcher.ts:84](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L84)
143
144Whether the batcher should start processing immediately
145
146#### Default
147
148```ts
149true
150```
151
152***
153
154### wait?
155
156```ts
157optional wait?: number | ((batcher) => number);
158```
159
160Defined in: [batcher.ts:91](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/batcher.ts#L91)
161
162Maximum time in milliseconds to wait before processing a batch.
163If the wait duration has elapsed, the batch will be processed.
164If not provided, the batch will not be triggered by a timeout.
165
166#### Default
167
168```ts
169Infinity
170```