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

AsyncDebouncerOptions.md

207 lines4.3 KB

1---
2id: AsyncDebouncerOptions
3title: AsyncDebouncerOptions
4---
5​
6Defined in: [async-debouncer.ts:71](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L71)
7​
8Options for configuring an async debounced function
9​
10## Type Parameters
11​
12### TFn
13​
14`TFn` *extends* [`AnyAsyncFunction`](../type-aliases/AnyAsyncFunction.md)
15​
16## Properties
17​
18### asyncRetryerOptions?
19​
20```ts
21optional asyncRetryerOptions?: AsyncRetryerOptions<TFn>;
22```
23​
24Defined in: [async-debouncer.ts:75](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L75)
25​
26Options for configuring the underlying async retryer
27​
28***
29​
30### enabled?
31​
32```ts
33optional enabled?: boolean | ((debouncer) => boolean);
34```
35​
36Defined in: [async-debouncer.ts:81](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L81)
37​
38Whether the debouncer is enabled. When disabled, maybeExecute will not trigger any executions.
39Can be a boolean or a function that returns a boolean.
40Defaults to true.
41​
42***
43​
44### initialState?
45​
46```ts
47optional initialState?: Partial<AsyncDebouncerState<TFn>>;
48```
49​
50Defined in: [async-debouncer.ts:85](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L85)
51​
52Initial state for the async debouncer
53​
54***
55​
56### key?
57​
58```ts
59optional key?: string;
60```
61​
62Defined in: [async-debouncer.ts:90](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L90)
63​
64Optional key to identify this async debouncer instance.
65If provided, the async debouncer will be identified by this key in the devtools and PacerProvider if applicable.
66​
67***
68​
69### leading?
70​
71```ts
72optional leading?: boolean;
73```
74​
75Defined in: [async-debouncer.ts:95](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L95)
76​
77Whether to execute on the leading edge of the timeout.
78Defaults to false.
79​
80***
81​
82### onError?
83​
84```ts
85optional onError?: (error, args, debouncer) => void;
86```
87​
88Defined in: [async-debouncer.ts:101](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L101)
89​
90Optional error handler for when the debounced function throws.
91If provided, the handler will be called with the error and debouncer instance.
92This can be used alongside throwOnError - the handler will be called before any error is thrown.
93​
94#### Parameters
95​
96##### error
97​
98`Error`
99​
100##### args
101​
102`Parameters`\<`TFn`\>
103​
104##### debouncer
105​
106[`AsyncDebouncer`](../classes/AsyncDebouncer.md)\<`TFn`\>
107​
108#### Returns
109​
110`void`
111​
112***
113​
114### onSettled?
115​
116```ts
117optional onSettled?: (args, debouncer) => void;
118```
119​
120Defined in: [async-debouncer.ts:109](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L109)
121​
122Optional callback to call when the debounced function is executed
123​
124#### Parameters
125​
126##### args
127​
128`Parameters`\<`TFn`\>
129​
130##### debouncer
131​
132[`AsyncDebouncer`](../classes/AsyncDebouncer.md)\<`TFn`\>
133​
134#### Returns
135​
136`void`
137​
138***
139​
140### onSuccess?
141​
142```ts
143optional onSuccess?: (result, args, debouncer) => void;
144```
145​
146Defined in: [async-debouncer.ts:113](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L113)
147​
148Optional callback to call when the debounced function is executed
149​
150#### Parameters
151​
152##### result
153​
154`Awaited`\<`ReturnType`\<`TFn`\>\>
155​
156##### args
157​
158`Parameters`\<`TFn`\>
159​
160##### debouncer
161​
162[`AsyncDebouncer`](../classes/AsyncDebouncer.md)\<`TFn`\>
163​
164#### Returns
165​
166`void`
167​
168***
169​
170### throwOnError?
171​
172```ts
173optional throwOnError?: boolean;
174```
175​
176Defined in: [async-debouncer.ts:123](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L123)
177​
178Whether to throw errors when they occur.
179Defaults to true if no onError handler is provided, false if an onError handler is provided.
180Can be explicitly set to override these defaults.
181​
182***
183​
184### trailing?
185​
186```ts
187optional trailing?: boolean;
188```
189​
190Defined in: [async-debouncer.ts:128](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L128)
191​
192Whether to execute on the trailing edge of the timeout.
193Defaults to true.
194​
195***
196​
197### wait
198​
199```ts
200wait: number | ((debouncer) => number);
201```
202​
203Defined in: [async-debouncer.ts:134](https://github.com/TanStack/pacer/blob/main/packages/pacer/src/async-debouncer.ts#L134)
204​
205Delay in milliseconds to wait after the last call before executing.
206Can be a number or a function that returns a number.
207Defaults to 0ms