@tanstack/solid-pacer 0.21.1 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -6
- package/dist/async-batcher/createAsyncBatcher.d.ts +5 -10
- package/dist/async-batcher/createAsyncBatcher.js +2 -5
- package/dist/async-debouncer/createAsyncDebouncer.d.ts +8 -12
- package/dist/async-debouncer/createAsyncDebouncer.js +5 -7
- package/dist/async-queuer/createAsyncQueuer.d.ts +9 -12
- package/dist/async-queuer/createAsyncQueuer.js +4 -5
- package/dist/async-rate-limiter/createAsyncRateLimiter.d.ts +10 -13
- package/dist/async-rate-limiter/createAsyncRateLimiter.js +7 -8
- package/dist/async-throttler/createAsyncThrottler.d.ts +8 -14
- package/dist/async-throttler/createAsyncThrottler.js +5 -9
- package/dist/batcher/createBatcher.d.ts +11 -15
- package/dist/batcher/createBatcher.js +6 -8
- package/dist/debouncer/createDebouncedSignal.d.ts +2 -5
- package/dist/debouncer/createDebouncedSignal.js +1 -2
- package/dist/debouncer/createDebouncedValue.d.ts +2 -5
- package/dist/debouncer/createDebouncedValue.js +1 -2
- package/dist/debouncer/createDebouncer.d.ts +4 -7
- package/dist/debouncer/createDebouncer.js +1 -2
- package/dist/provider/PacerProvider.d.ts +6 -9
- package/dist/provider/PacerProvider.js +1 -2
- package/dist/queuer/createQueuedSignal.d.ts +2 -5
- package/dist/queuer/createQueuedSignal.js +1 -2
- package/dist/queuer/createQueuer.d.ts +4 -7
- package/dist/queuer/createQueuer.js +1 -2
- package/dist/rate-limiter/createRateLimitedSignal.d.ts +12 -14
- package/dist/rate-limiter/createRateLimitedSignal.js +11 -11
- package/dist/rate-limiter/createRateLimitedValue.d.ts +2 -5
- package/dist/rate-limiter/createRateLimitedValue.js +1 -2
- package/dist/rate-limiter/createRateLimiter.d.ts +8 -10
- package/dist/rate-limiter/createRateLimiter.js +5 -5
- package/dist/throttler/createThrottledSignal.d.ts +2 -7
- package/dist/throttler/createThrottledSignal.js +1 -4
- package/dist/throttler/createThrottledValue.d.ts +2 -7
- package/dist/throttler/createThrottledValue.js +1 -4
- package/dist/throttler/createThrottler.d.ts +4 -9
- package/dist/throttler/createThrottler.js +1 -4
- package/package.json +24 -68
- package/dist/async-batcher/createAsyncBatcher.cjs +0 -166
- package/dist/async-batcher/createAsyncBatcher.cjs.map +0 -1
- package/dist/async-batcher/createAsyncBatcher.d.cts +0 -178
- package/dist/async-batcher/createAsyncBatcher.js.map +0 -1
- package/dist/async-batcher/index.cjs +0 -11
- package/dist/async-batcher/index.d.cts +0 -3
- package/dist/async-debouncer/createAsyncDebouncer.cjs +0 -151
- package/dist/async-debouncer/createAsyncDebouncer.cjs.map +0 -1
- package/dist/async-debouncer/createAsyncDebouncer.d.cts +0 -164
- package/dist/async-debouncer/createAsyncDebouncer.js.map +0 -1
- package/dist/async-debouncer/index.cjs +0 -11
- package/dist/async-debouncer/index.d.cts +0 -3
- package/dist/async-queuer/createAsyncQueuer.cjs +0 -158
- package/dist/async-queuer/createAsyncQueuer.cjs.map +0 -1
- package/dist/async-queuer/createAsyncQueuer.d.cts +0 -170
- package/dist/async-queuer/createAsyncQueuer.js.map +0 -1
- package/dist/async-queuer/index.cjs +0 -11
- package/dist/async-queuer/index.d.cts +0 -3
- package/dist/async-rate-limiter/createAsyncRateLimiter.cjs +0 -193
- package/dist/async-rate-limiter/createAsyncRateLimiter.cjs.map +0 -1
- package/dist/async-rate-limiter/createAsyncRateLimiter.d.cts +0 -209
- package/dist/async-rate-limiter/createAsyncRateLimiter.js.map +0 -1
- package/dist/async-rate-limiter/index.cjs +0 -11
- package/dist/async-rate-limiter/index.d.cts +0 -3
- package/dist/async-throttler/createAsyncThrottler.cjs +0 -151
- package/dist/async-throttler/createAsyncThrottler.cjs.map +0 -1
- package/dist/async-throttler/createAsyncThrottler.d.cts +0 -164
- package/dist/async-throttler/createAsyncThrottler.js.map +0 -1
- package/dist/async-throttler/index.cjs +0 -11
- package/dist/async-throttler/index.d.cts +0 -3
- package/dist/batcher/createBatcher.cjs +0 -132
- package/dist/batcher/createBatcher.cjs.map +0 -1
- package/dist/batcher/createBatcher.d.cts +0 -147
- package/dist/batcher/createBatcher.js.map +0 -1
- package/dist/batcher/index.cjs +0 -11
- package/dist/batcher/index.d.cts +0 -3
- package/dist/debouncer/createDebouncedSignal.cjs +0 -88
- package/dist/debouncer/createDebouncedSignal.cjs.map +0 -1
- package/dist/debouncer/createDebouncedSignal.d.cts +0 -80
- package/dist/debouncer/createDebouncedSignal.js.map +0 -1
- package/dist/debouncer/createDebouncedValue.cjs +0 -77
- package/dist/debouncer/createDebouncedValue.cjs.map +0 -1
- package/dist/debouncer/createDebouncedValue.d.cts +0 -71
- package/dist/debouncer/createDebouncedValue.js.map +0 -1
- package/dist/debouncer/createDebouncer.cjs +0 -129
- package/dist/debouncer/createDebouncer.cjs.map +0 -1
- package/dist/debouncer/createDebouncer.d.cts +0 -145
- package/dist/debouncer/createDebouncer.js.map +0 -1
- package/dist/debouncer/index.cjs +0 -15
- package/dist/debouncer/index.d.cts +0 -5
- package/dist/index.cjs +0 -47
- package/dist/index.d.cts +0 -20
- package/dist/provider/PacerProvider.cjs +0 -27
- package/dist/provider/PacerProvider.cjs.map +0 -1
- package/dist/provider/PacerProvider.d.cts +0 -29
- package/dist/provider/PacerProvider.js.map +0 -1
- package/dist/provider/index.cjs +0 -6
- package/dist/provider/index.d.cts +0 -2
- package/dist/queuer/createQueuedSignal.cjs +0 -129
- package/dist/queuer/createQueuedSignal.cjs.map +0 -1
- package/dist/queuer/createQueuedSignal.d.cts +0 -122
- package/dist/queuer/createQueuedSignal.js.map +0 -1
- package/dist/queuer/createQueuer.cjs +0 -133
- package/dist/queuer/createQueuer.cjs.map +0 -1
- package/dist/queuer/createQueuer.d.cts +0 -148
- package/dist/queuer/createQueuer.js.map +0 -1
- package/dist/queuer/index.cjs +0 -13
- package/dist/queuer/index.d.cts +0 -4
- package/dist/rate-limiter/createRateLimitedSignal.cjs +0 -102
- package/dist/rate-limiter/createRateLimitedSignal.cjs.map +0 -1
- package/dist/rate-limiter/createRateLimitedSignal.d.cts +0 -94
- package/dist/rate-limiter/createRateLimitedSignal.js.map +0 -1
- package/dist/rate-limiter/createRateLimitedValue.cjs +0 -102
- package/dist/rate-limiter/createRateLimitedValue.cjs.map +0 -1
- package/dist/rate-limiter/createRateLimitedValue.d.cts +0 -96
- package/dist/rate-limiter/createRateLimitedValue.js.map +0 -1
- package/dist/rate-limiter/createRateLimiter.cjs +0 -157
- package/dist/rate-limiter/createRateLimiter.cjs.map +0 -1
- package/dist/rate-limiter/createRateLimiter.d.cts +0 -174
- package/dist/rate-limiter/createRateLimiter.js.map +0 -1
- package/dist/rate-limiter/index.cjs +0 -15
- package/dist/rate-limiter/index.d.cts +0 -5
- package/dist/throttler/createThrottledSignal.cjs +0 -79
- package/dist/throttler/createThrottledSignal.cjs.map +0 -1
- package/dist/throttler/createThrottledSignal.d.cts +0 -71
- package/dist/throttler/createThrottledSignal.js.map +0 -1
- package/dist/throttler/createThrottledValue.cjs +0 -74
- package/dist/throttler/createThrottledValue.cjs.map +0 -1
- package/dist/throttler/createThrottledValue.d.cts +0 -68
- package/dist/throttler/createThrottledValue.js.map +0 -1
- package/dist/throttler/createThrottler.cjs +0 -132
- package/dist/throttler/createThrottler.cjs.map +0 -1
- package/dist/throttler/createThrottler.d.cts +0 -148
- package/dist/throttler/createThrottler.js.map +0 -1
- package/dist/throttler/index.cjs +0 -15
- package/dist/throttler/index.d.cts +0 -5
- package/dist/types/index.cjs +0 -9
- package/dist/types/index.d.cts +0 -1
- package/dist/utils/index.cjs +0 -9
- package/dist/utils/index.d.cts +0 -1
- package/src/async-batcher/createAsyncBatcher.ts +0 -234
- package/src/async-batcher/index.ts +0 -3
- package/src/async-debouncer/createAsyncDebouncer.ts +0 -225
- package/src/async-debouncer/index.ts +0 -4
- package/src/async-queuer/createAsyncQueuer.ts +0 -226
- package/src/async-queuer/index.ts +0 -3
- package/src/async-rate-limiter/createAsyncRateLimiter.ts +0 -269
- package/src/async-rate-limiter/index.ts +0 -4
- package/src/async-throttler/createAsyncThrottler.ts +0 -225
- package/src/async-throttler/index.ts +0 -4
- package/src/batcher/createBatcher.ts +0 -199
- package/src/batcher/index.ts +0 -3
- package/src/debouncer/createDebouncedSignal.ts +0 -92
- package/src/debouncer/createDebouncedValue.ts +0 -85
- package/src/debouncer/createDebouncer.ts +0 -201
- package/src/debouncer/index.ts +0 -6
- package/src/index.ts +0 -46
- package/src/provider/PacerProvider.tsx +0 -63
- package/src/provider/index.ts +0 -1
- package/src/queuer/createQueuedSignal.ts +0 -138
- package/src/queuer/createQueuer.ts +0 -199
- package/src/queuer/index.ts +0 -4
- package/src/rate-limiter/createRateLimitedSignal.ts +0 -117
- package/src/rate-limiter/createRateLimitedValue.ts +0 -110
- package/src/rate-limiter/createRateLimiter.ts +0 -226
- package/src/rate-limiter/index.ts +0 -5
- package/src/throttler/createThrottledSignal.ts +0 -81
- package/src/throttler/createThrottledValue.ts +0 -82
- package/src/throttler/createThrottler.ts +0 -204
- package/src/throttler/index.ts +0 -6
- package/src/types/index.ts +0 -1
- package/src/utils/index.ts +0 -1
package/README.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<
|
|
2
|
+
<picture>
|
|
3
|
+
<source
|
|
4
|
+
media="(prefers-color-scheme: dark)"
|
|
5
|
+
srcset="https://tanstack.com/api/readme/pacer.png?theme=dark"
|
|
6
|
+
/>
|
|
7
|
+
<source
|
|
8
|
+
media="(prefers-color-scheme: light)"
|
|
9
|
+
srcset="https://tanstack.com/api/readme/pacer.png"
|
|
10
|
+
/>
|
|
11
|
+
<img
|
|
12
|
+
src="https://tanstack.com/api/readme/pacer.png"
|
|
13
|
+
alt="TanStack Pacer"
|
|
14
|
+
width="900"
|
|
15
|
+
/>
|
|
16
|
+
</picture>
|
|
3
17
|
</div>
|
|
4
18
|
|
|
5
19
|
<br />
|
|
@@ -29,8 +43,9 @@
|
|
|
29
43
|
</div>
|
|
30
44
|
|
|
31
45
|
<div align="center">
|
|
32
|
-
|
|
46
|
+
|
|
33
47
|
### [Become a Sponsor!](https://github.com/sponsors/tannerlinsley/)
|
|
48
|
+
|
|
34
49
|
</div>
|
|
35
50
|
|
|
36
51
|
# TanStack Pacer
|
|
@@ -88,10 +103,10 @@ A lightweight timing and scheduling library for debouncing, throttling, rate lim
|
|
|
88
103
|
> [!NOTE]
|
|
89
104
|
> You may know **TanStack Pacer** by our adapter names, too!
|
|
90
105
|
>
|
|
91
|
-
> - [**React Pacer**](https://tanstack.com/pacer/latest/docs/framework/react
|
|
92
|
-
> - [**Preact Pacer**](https://tanstack.com/pacer/latest/docs/framework/preact
|
|
93
|
-
> - [**Solid Pacer**](https://tanstack.com/pacer/latest/docs/framework/solid
|
|
94
|
-
> - [**Angular Pacer**](https://tanstack.com/pacer/latest/docs/framework/angular
|
|
106
|
+
> - [**React Pacer**](https://tanstack.com/pacer/latest/docs/framework/react)
|
|
107
|
+
> - [**Preact Pacer**](https://tanstack.com/pacer/latest/docs/framework/preact)
|
|
108
|
+
> - [**Solid Pacer**](https://tanstack.com/pacer/latest/docs/framework/solid)
|
|
109
|
+
> - [**Angular Pacer**](https://tanstack.com/pacer/latest/docs/framework/angular)
|
|
95
110
|
> - Svelte Pacer - needs a contributor!
|
|
96
111
|
> - Vue Pacer - needs a contributor!
|
|
97
112
|
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { Accessor, JSX } from "solid-js";
|
|
2
2
|
import { AsyncBatcher, AsyncBatcherOptions, AsyncBatcherState } from "@tanstack/pacer/async-batcher";
|
|
3
3
|
import { Store } from "@tanstack/solid-store";
|
|
4
|
-
|
|
5
4
|
//#region src/async-batcher/createAsyncBatcher.d.ts
|
|
6
|
-
interface SolidAsyncBatcherOptions<TValue, TSelected = {}> extends AsyncBatcherOptions<TValue> {
|
|
5
|
+
export interface SolidAsyncBatcherOptions<TValue, TSelected = {}> extends AsyncBatcherOptions<TValue> {
|
|
7
6
|
/**
|
|
8
7
|
* Optional callback invoked when the owning component unmounts. Receives the batcher instance.
|
|
9
8
|
* When provided, replaces the default cleanup (cancel + abort); use it to call flush(), reset(), cancel(), add logging, etc.
|
|
10
9
|
*/
|
|
11
10
|
onUnmount?: (batcher: SolidAsyncBatcher<TValue, TSelected>) => void;
|
|
12
11
|
}
|
|
13
|
-
interface SolidAsyncBatcher<TValue, TSelected = {}> extends Omit<AsyncBatcher<TValue>, 'store'> {
|
|
12
|
+
export interface SolidAsyncBatcher<TValue, TSelected = {}> extends Omit<AsyncBatcher<TValue>, 'store'> {
|
|
14
13
|
/**
|
|
15
14
|
* A Solid component that allows you to subscribe to the batcher state.
|
|
16
15
|
*
|
|
@@ -95,10 +94,8 @@ interface SolidAsyncBatcher<TValue, TSelected = {}> extends Omit<AsyncBatcher<TV
|
|
|
95
94
|
* Available state properties:
|
|
96
95
|
* - `errorCount`: Number of failed batch executions
|
|
97
96
|
* - `executionCount`: Total number of batch execution attempts (successful + failed)
|
|
98
|
-
* - `hasError`: Whether the last batch execution resulted in an error
|
|
99
97
|
* - `isExecuting`: Whether a batch execution is currently in progress
|
|
100
98
|
* - `items`: Array of items currently queued for batching
|
|
101
|
-
* - `lastError`: The error from the most recent failed batch execution (if any)
|
|
102
99
|
* - `lastResult`: The result from the most recent successful batch execution
|
|
103
100
|
* - `settleCount`: Number of batch executions that have completed (successful or failed)
|
|
104
101
|
* - `successCount`: Number of successful batch executions
|
|
@@ -159,7 +156,7 @@ interface SolidAsyncBatcher<TValue, TSelected = {}> extends Omit<AsyncBatcher<TV
|
|
|
159
156
|
* return results;
|
|
160
157
|
* },
|
|
161
158
|
* { maxSize: 10, wait: 2000 },
|
|
162
|
-
* (state) => ({
|
|
159
|
+
* (state) => ({ errorCount: state.errorCount })
|
|
163
160
|
* );
|
|
164
161
|
*
|
|
165
162
|
* // Add items to batch
|
|
@@ -172,7 +169,5 @@ interface SolidAsyncBatcher<TValue, TSelected = {}> extends Omit<AsyncBatcher<TV
|
|
|
172
169
|
* const { items, isExecuting } = asyncBatcher.state();
|
|
173
170
|
* ```
|
|
174
171
|
*/
|
|
175
|
-
declare function createAsyncBatcher<TValue, TSelected = {}>(fn: (items: Array<TValue>) => Promise<any>, options?: SolidAsyncBatcherOptions<TValue, TSelected>, selector?: (state: AsyncBatcherState<TValue>) => TSelected): SolidAsyncBatcher<TValue, TSelected>;
|
|
176
|
-
//#endregion
|
|
177
|
-
export { SolidAsyncBatcher, SolidAsyncBatcherOptions, createAsyncBatcher };
|
|
178
|
-
//# sourceMappingURL=createAsyncBatcher.d.ts.map
|
|
172
|
+
export declare function createAsyncBatcher<TValue, TSelected = {}>(fn: (items: Array<TValue>) => Promise<any>, options?: SolidAsyncBatcherOptions<TValue, TSelected>, selector?: (state: AsyncBatcherState<TValue>) => TSelected): SolidAsyncBatcher<TValue, TSelected>;
|
|
173
|
+
//#endregion
|
|
@@ -58,10 +58,8 @@ import { shallow, useSelector } from "@tanstack/solid-store";
|
|
|
58
58
|
* Available state properties:
|
|
59
59
|
* - `errorCount`: Number of failed batch executions
|
|
60
60
|
* - `executionCount`: Total number of batch execution attempts (successful + failed)
|
|
61
|
-
* - `hasError`: Whether the last batch execution resulted in an error
|
|
62
61
|
* - `isExecuting`: Whether a batch execution is currently in progress
|
|
63
62
|
* - `items`: Array of items currently queued for batching
|
|
64
|
-
* - `lastError`: The error from the most recent failed batch execution (if any)
|
|
65
63
|
* - `lastResult`: The result from the most recent successful batch execution
|
|
66
64
|
* - `settleCount`: Number of batch executions that have completed (successful or failed)
|
|
67
65
|
* - `successCount`: Number of successful batch executions
|
|
@@ -122,7 +120,7 @@ import { shallow, useSelector } from "@tanstack/solid-store";
|
|
|
122
120
|
* return results;
|
|
123
121
|
* },
|
|
124
122
|
* { maxSize: 10, wait: 2000 },
|
|
125
|
-
* (state) => ({
|
|
123
|
+
* (state) => ({ errorCount: state.errorCount })
|
|
126
124
|
* );
|
|
127
125
|
*
|
|
128
126
|
* // Add items to batch
|
|
@@ -162,5 +160,4 @@ function createAsyncBatcher(fn, options = {}, selector = () => ({})) {
|
|
|
162
160
|
}
|
|
163
161
|
|
|
164
162
|
//#endregion
|
|
165
|
-
export { createAsyncBatcher };
|
|
166
|
-
//# sourceMappingURL=createAsyncBatcher.js.map
|
|
163
|
+
export { createAsyncBatcher };
|
|
@@ -2,16 +2,15 @@ import { Accessor, JSX } from "solid-js";
|
|
|
2
2
|
import { Store } from "@tanstack/solid-store";
|
|
3
3
|
import { AsyncDebouncer, AsyncDebouncerOptions, AsyncDebouncerState } from "@tanstack/pacer/async-debouncer";
|
|
4
4
|
import { AnyAsyncFunction } from "@tanstack/pacer/types";
|
|
5
|
-
|
|
6
5
|
//#region src/async-debouncer/createAsyncDebouncer.d.ts
|
|
7
|
-
interface SolidAsyncDebouncerOptions<TFn extends AnyAsyncFunction, TSelected = {}> extends AsyncDebouncerOptions<TFn> {
|
|
6
|
+
export interface SolidAsyncDebouncerOptions<TFn extends AnyAsyncFunction, TSelected = {}> extends AsyncDebouncerOptions<TFn> {
|
|
8
7
|
/**
|
|
9
8
|
* Optional callback invoked when the owning component unmounts. Receives the debouncer instance.
|
|
10
9
|
* When provided, replaces the default cleanup (cancel + abort); use it to call flush(), reset(), cancel(), add logging, etc.
|
|
11
10
|
*/
|
|
12
11
|
onUnmount?: (debouncer: SolidAsyncDebouncer<TFn, TSelected>) => void;
|
|
13
12
|
}
|
|
14
|
-
interface SolidAsyncDebouncer<TFn extends AnyAsyncFunction, TSelected = {}> extends Omit<AsyncDebouncer<TFn>, 'store'> {
|
|
13
|
+
export interface SolidAsyncDebouncer<TFn extends AnyAsyncFunction, TSelected = {}> extends Omit<AsyncDebouncer<TFn>, 'store'> {
|
|
15
14
|
/**
|
|
16
15
|
* A Solid component that allows you to subscribe to the debouncer state.
|
|
17
16
|
*
|
|
@@ -89,14 +88,13 @@ interface SolidAsyncDebouncer<TFn extends AnyAsyncFunction, TSelected = {}> exte
|
|
|
89
88
|
*
|
|
90
89
|
* Available state properties:
|
|
91
90
|
* - `canLeadingExecute`: Whether the debouncer can execute on the leading edge
|
|
92
|
-
* - `
|
|
93
|
-
* - `
|
|
91
|
+
* - `settleCount`: Number of function executions that have completed (success or error)
|
|
92
|
+
* - `errorCount`: Number of function executions that have resulted in errors
|
|
94
93
|
* - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution
|
|
95
94
|
* - `isExecuting`: Whether an async function execution is currently in progress
|
|
96
95
|
* - `lastArgs`: The arguments from the most recent call to maybeExecute
|
|
97
|
-
* - `lastError`: The error from the most recent failed execution (if any)
|
|
98
96
|
* - `lastResult`: The result from the most recent successful execution
|
|
99
|
-
* - `status`: Current execution status ('disabled' | 'idle' | 'pending' | 'executing')
|
|
97
|
+
* - `status`: Current execution status ('disabled' | 'idle' | 'pending' | 'executing' | 'settled')
|
|
100
98
|
*
|
|
101
99
|
* ## Unmount behavior
|
|
102
100
|
*
|
|
@@ -151,14 +149,12 @@ interface SolidAsyncDebouncer<TFn extends AnyAsyncFunction, TSelected = {}> exte
|
|
|
151
149
|
* console.error('API call failed:', error);
|
|
152
150
|
* }
|
|
153
151
|
* },
|
|
154
|
-
* (state) => ({
|
|
152
|
+
* (state) => ({ errorCount: state.errorCount })
|
|
155
153
|
* );
|
|
156
154
|
*
|
|
157
155
|
* // Access the selected state (will be empty object {} unless selector provided)
|
|
158
156
|
* const { isPending, isExecuting } = debouncer.state();
|
|
159
157
|
* ```
|
|
160
158
|
*/
|
|
161
|
-
declare function createAsyncDebouncer<TFn extends AnyAsyncFunction, TSelected = {}>(fn: TFn, options: SolidAsyncDebouncerOptions<TFn, TSelected>, selector?: (state: AsyncDebouncerState<TFn>) => TSelected): SolidAsyncDebouncer<TFn, TSelected>;
|
|
162
|
-
//#endregion
|
|
163
|
-
export { SolidAsyncDebouncer, SolidAsyncDebouncerOptions, createAsyncDebouncer };
|
|
164
|
-
//# sourceMappingURL=createAsyncDebouncer.d.ts.map
|
|
159
|
+
export declare function createAsyncDebouncer<TFn extends AnyAsyncFunction, TSelected = {}>(fn: TFn, options: SolidAsyncDebouncerOptions<TFn, TSelected>, selector?: (state: AsyncDebouncerState<TFn>) => TSelected): SolidAsyncDebouncer<TFn, TSelected>;
|
|
160
|
+
//#endregion
|
|
@@ -51,14 +51,13 @@ import { AsyncDebouncer } from "@tanstack/pacer/async-debouncer";
|
|
|
51
51
|
*
|
|
52
52
|
* Available state properties:
|
|
53
53
|
* - `canLeadingExecute`: Whether the debouncer can execute on the leading edge
|
|
54
|
-
* - `
|
|
55
|
-
* - `
|
|
54
|
+
* - `settleCount`: Number of function executions that have completed (success or error)
|
|
55
|
+
* - `errorCount`: Number of function executions that have resulted in errors
|
|
56
56
|
* - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution
|
|
57
57
|
* - `isExecuting`: Whether an async function execution is currently in progress
|
|
58
58
|
* - `lastArgs`: The arguments from the most recent call to maybeExecute
|
|
59
|
-
* - `lastError`: The error from the most recent failed execution (if any)
|
|
60
59
|
* - `lastResult`: The result from the most recent successful execution
|
|
61
|
-
* - `status`: Current execution status ('disabled' | 'idle' | 'pending' | 'executing')
|
|
60
|
+
* - `status`: Current execution status ('disabled' | 'idle' | 'pending' | 'executing' | 'settled')
|
|
62
61
|
*
|
|
63
62
|
* ## Unmount behavior
|
|
64
63
|
*
|
|
@@ -113,7 +112,7 @@ import { AsyncDebouncer } from "@tanstack/pacer/async-debouncer";
|
|
|
113
112
|
* console.error('API call failed:', error);
|
|
114
113
|
* }
|
|
115
114
|
* },
|
|
116
|
-
* (state) => ({
|
|
115
|
+
* (state) => ({ errorCount: state.errorCount })
|
|
117
116
|
* );
|
|
118
117
|
*
|
|
119
118
|
* // Access the selected state (will be empty object {} unless selector provided)
|
|
@@ -147,5 +146,4 @@ function createAsyncDebouncer(fn, options, selector = () => ({})) {
|
|
|
147
146
|
}
|
|
148
147
|
|
|
149
148
|
//#endregion
|
|
150
|
-
export { createAsyncDebouncer };
|
|
151
|
-
//# sourceMappingURL=createAsyncDebouncer.js.map
|
|
149
|
+
export { createAsyncDebouncer };
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { Accessor, JSX } from "solid-js";
|
|
2
2
|
import { Store } from "@tanstack/solid-store";
|
|
3
3
|
import { AsyncQueuer, AsyncQueuerOptions, AsyncQueuerState } from "@tanstack/pacer/async-queuer";
|
|
4
|
-
|
|
5
4
|
//#region src/async-queuer/createAsyncQueuer.d.ts
|
|
6
|
-
interface SolidAsyncQueuerOptions<TValue, TSelected = {}> extends AsyncQueuerOptions<TValue> {
|
|
5
|
+
export interface SolidAsyncQueuerOptions<TValue, TSelected = {}> extends AsyncQueuerOptions<TValue> {
|
|
7
6
|
/**
|
|
8
7
|
* Optional callback invoked when the owning component unmounts. Receives the queuer instance.
|
|
9
8
|
* When provided, replaces the default cleanup (stop + abort); use it to call flush(), flushAsBatch(), stop(), add logging, etc.
|
|
10
9
|
*/
|
|
11
10
|
onUnmount?: (queuer: SolidAsyncQueuer<TValue, TSelected>) => void;
|
|
12
11
|
}
|
|
13
|
-
interface SolidAsyncQueuer<TValue, TSelected = {}> extends Omit<AsyncQueuer<TValue>, 'store'> {
|
|
12
|
+
export interface SolidAsyncQueuer<TValue, TSelected = {}> extends Omit<AsyncQueuer<TValue>, 'store'> {
|
|
14
13
|
/**
|
|
15
14
|
* A Solid component that allows you to subscribe to the queuer state.
|
|
16
15
|
*
|
|
@@ -18,9 +17,9 @@ interface SolidAsyncQueuer<TValue, TSelected = {}> extends Omit<AsyncQueuer<TVal
|
|
|
18
17
|
* deep in your component tree without needing to pass a selector to the hook.
|
|
19
18
|
*
|
|
20
19
|
* @example
|
|
21
|
-
* <queuer.Subscribe selector={(state) => ({
|
|
20
|
+
* <queuer.Subscribe selector={(state) => ({ items: state.items, activeItems: state.activeItems })}>
|
|
22
21
|
* {(state) => (
|
|
23
|
-
* <div>Pending: {state().
|
|
22
|
+
* <div>Pending: {state().items.length}, Active: {state().activeItems.length}</div>
|
|
24
23
|
* )}
|
|
25
24
|
* </queuer.Subscribe>
|
|
26
25
|
*/
|
|
@@ -89,7 +88,7 @@ interface SolidAsyncQueuer<TValue, TSelected = {}> extends Omit<AsyncQueuer<TVal
|
|
|
89
88
|
* - `activeItems`: Array of items currently being processed
|
|
90
89
|
* - `errorCount`: Number of items that failed processing
|
|
91
90
|
* - `isRunning`: Whether the queuer is currently running (not stopped)
|
|
92
|
-
* - `
|
|
91
|
+
* - `items`: Array of items waiting to be processed
|
|
93
92
|
* - `rejectionCount`: Number of items that were rejected (expired or failed validation)
|
|
94
93
|
* - `settleCount`: Number of items that have completed processing (successful or failed)
|
|
95
94
|
* - `successCount`: Number of items that were processed successfully
|
|
@@ -137,7 +136,7 @@ interface SolidAsyncQueuer<TValue, TSelected = {}> extends Omit<AsyncQueuer<TVal
|
|
|
137
136
|
* async (item) => await fetchData(item),
|
|
138
137
|
* { concurrency: 2, started: true },
|
|
139
138
|
* (state) => ({
|
|
140
|
-
*
|
|
139
|
+
* items: state.items,
|
|
141
140
|
* activeItems: state.activeItems,
|
|
142
141
|
* isRunning: state.isRunning
|
|
143
142
|
* })
|
|
@@ -161,10 +160,8 @@ interface SolidAsyncQueuer<TValue, TSelected = {}> extends Omit<AsyncQueuer<TVal
|
|
|
161
160
|
* asyncQueuer.start();
|
|
162
161
|
*
|
|
163
162
|
* // Access the selected state (will be empty object {} unless selector provided)
|
|
164
|
-
* const {
|
|
163
|
+
* const { items, activeItems } = asyncQueuer.state();
|
|
165
164
|
* ```
|
|
166
165
|
*/
|
|
167
|
-
declare function createAsyncQueuer<TValue, TSelected = {}>(fn: (value: TValue) => Promise<any>, options?: SolidAsyncQueuerOptions<TValue, TSelected>, selector?: (state: AsyncQueuerState<TValue>) => TSelected): SolidAsyncQueuer<TValue, TSelected>;
|
|
168
|
-
//#endregion
|
|
169
|
-
export { SolidAsyncQueuer, SolidAsyncQueuerOptions, createAsyncQueuer };
|
|
170
|
-
//# sourceMappingURL=createAsyncQueuer.d.ts.map
|
|
166
|
+
export declare function createAsyncQueuer<TValue, TSelected = {}>(fn: (value: TValue) => Promise<any>, options?: SolidAsyncQueuerOptions<TValue, TSelected>, selector?: (state: AsyncQueuerState<TValue>) => TSelected): SolidAsyncQueuer<TValue, TSelected>;
|
|
167
|
+
//#endregion
|
|
@@ -52,7 +52,7 @@ import { AsyncQueuer } from "@tanstack/pacer/async-queuer";
|
|
|
52
52
|
* - `activeItems`: Array of items currently being processed
|
|
53
53
|
* - `errorCount`: Number of items that failed processing
|
|
54
54
|
* - `isRunning`: Whether the queuer is currently running (not stopped)
|
|
55
|
-
* - `
|
|
55
|
+
* - `items`: Array of items waiting to be processed
|
|
56
56
|
* - `rejectionCount`: Number of items that were rejected (expired or failed validation)
|
|
57
57
|
* - `settleCount`: Number of items that have completed processing (successful or failed)
|
|
58
58
|
* - `successCount`: Number of items that were processed successfully
|
|
@@ -100,7 +100,7 @@ import { AsyncQueuer } from "@tanstack/pacer/async-queuer";
|
|
|
100
100
|
* async (item) => await fetchData(item),
|
|
101
101
|
* { concurrency: 2, started: true },
|
|
102
102
|
* (state) => ({
|
|
103
|
-
*
|
|
103
|
+
* items: state.items,
|
|
104
104
|
* activeItems: state.activeItems,
|
|
105
105
|
* isRunning: state.isRunning
|
|
106
106
|
* })
|
|
@@ -124,7 +124,7 @@ import { AsyncQueuer } from "@tanstack/pacer/async-queuer";
|
|
|
124
124
|
* asyncQueuer.start();
|
|
125
125
|
*
|
|
126
126
|
* // Access the selected state (will be empty object {} unless selector provided)
|
|
127
|
-
* const {
|
|
127
|
+
* const { items, activeItems } = asyncQueuer.state();
|
|
128
128
|
* ```
|
|
129
129
|
*/
|
|
130
130
|
function createAsyncQueuer(fn, options = {}, selector = () => ({})) {
|
|
@@ -154,5 +154,4 @@ function createAsyncQueuer(fn, options = {}, selector = () => ({})) {
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
//#endregion
|
|
157
|
-
export { createAsyncQueuer };
|
|
158
|
-
//# sourceMappingURL=createAsyncQueuer.js.map
|
|
157
|
+
export { createAsyncQueuer };
|
|
@@ -2,16 +2,15 @@ import { Accessor, JSX } from "solid-js";
|
|
|
2
2
|
import { Store } from "@tanstack/solid-store";
|
|
3
3
|
import { AsyncRateLimiter, AsyncRateLimiterOptions, AsyncRateLimiterState } from "@tanstack/pacer/async-rate-limiter";
|
|
4
4
|
import { AnyAsyncFunction } from "@tanstack/pacer/types";
|
|
5
|
-
|
|
6
5
|
//#region src/async-rate-limiter/createAsyncRateLimiter.d.ts
|
|
7
|
-
interface SolidAsyncRateLimiterOptions<TFn extends AnyAsyncFunction, TSelected = {}> extends AsyncRateLimiterOptions<TFn> {
|
|
6
|
+
export interface SolidAsyncRateLimiterOptions<TFn extends AnyAsyncFunction, TSelected = {}> extends AsyncRateLimiterOptions<TFn> {
|
|
8
7
|
/**
|
|
9
8
|
* Optional callback invoked when the owning component unmounts. Receives the rate limiter instance.
|
|
10
9
|
* When provided, replaces the default cleanup (abort); use it to call reset(), add logging, etc.
|
|
11
10
|
*/
|
|
12
11
|
onUnmount?: (rateLimiter: SolidAsyncRateLimiter<TFn, TSelected>) => void;
|
|
13
12
|
}
|
|
14
|
-
interface SolidAsyncRateLimiter<TFn extends AnyAsyncFunction, TSelected = {}> extends Omit<AsyncRateLimiter<TFn>, 'store'> {
|
|
13
|
+
export interface SolidAsyncRateLimiter<TFn extends AnyAsyncFunction, TSelected = {}> extends Omit<AsyncRateLimiter<TFn>, 'store'> {
|
|
15
14
|
/**
|
|
16
15
|
* A Solid component that allows you to subscribe to the rate limiter state.
|
|
17
16
|
*
|
|
@@ -98,16 +97,16 @@ interface SolidAsyncRateLimiter<TFn extends AnyAsyncFunction, TSelected = {}> ex
|
|
|
98
97
|
* tracking by providing a selector function or using the `Subscribe` component. This prevents unnecessary
|
|
99
98
|
* updates and gives you full control over when your component tracks state changes.
|
|
100
99
|
*
|
|
100
|
+
* Use `getRemainingInWindow()` and `getMsUntilNextWindow()` for current window capacity and timing.
|
|
101
|
+
*
|
|
101
102
|
* Available state properties:
|
|
102
|
-
* - `
|
|
103
|
-
* - `
|
|
104
|
-
* - `
|
|
103
|
+
* - `executionTimes`: Timestamps of executions tracked for the current window
|
|
104
|
+
* - `isExceeded`: Whether the rate limit has been reached
|
|
105
|
+
* - `settleCount`: Number of function executions that have completed (success or error)
|
|
106
|
+
* - `errorCount`: Number of function executions that have resulted in errors
|
|
105
107
|
* - `isExecuting`: Whether an async function execution is currently in progress
|
|
106
|
-
* - `lastError`: The error from the most recent failed execution (if any)
|
|
107
108
|
* - `lastResult`: The result from the most recent successful execution
|
|
108
|
-
* - `nextWindowTime`: Timestamp when the next window begins
|
|
109
109
|
* - `rejectionCount`: Number of function calls that were rejected due to rate limiting
|
|
110
|
-
* - `remainingInWindow`: Number of executions remaining in the current window
|
|
111
110
|
*
|
|
112
111
|
* ## Unmount behavior
|
|
113
112
|
*
|
|
@@ -203,7 +202,5 @@ interface SolidAsyncRateLimiter<TFn extends AnyAsyncFunction, TSelected = {}> ex
|
|
|
203
202
|
* const { isExecuting, lastResult, rejectionCount } = asyncRateLimiter.state();
|
|
204
203
|
* ```
|
|
205
204
|
*/
|
|
206
|
-
declare function createAsyncRateLimiter<TFn extends AnyAsyncFunction, TSelected = {}>(fn: TFn, options: SolidAsyncRateLimiterOptions<TFn, TSelected>, selector?: (state: AsyncRateLimiterState<TFn>) => TSelected): SolidAsyncRateLimiter<TFn, TSelected>;
|
|
207
|
-
//#endregion
|
|
208
|
-
export { SolidAsyncRateLimiter, SolidAsyncRateLimiterOptions, createAsyncRateLimiter };
|
|
209
|
-
//# sourceMappingURL=createAsyncRateLimiter.d.ts.map
|
|
205
|
+
export declare function createAsyncRateLimiter<TFn extends AnyAsyncFunction, TSelected = {}>(fn: TFn, options: SolidAsyncRateLimiterOptions<TFn, TSelected>, selector?: (state: AsyncRateLimiterState<TFn>) => TSelected): SolidAsyncRateLimiter<TFn, TSelected>;
|
|
206
|
+
//#endregion
|
|
@@ -60,16 +60,16 @@ import { AsyncRateLimiter } from "@tanstack/pacer/async-rate-limiter";
|
|
|
60
60
|
* tracking by providing a selector function or using the `Subscribe` component. This prevents unnecessary
|
|
61
61
|
* updates and gives you full control over when your component tracks state changes.
|
|
62
62
|
*
|
|
63
|
+
* Use `getRemainingInWindow()` and `getMsUntilNextWindow()` for current window capacity and timing.
|
|
64
|
+
*
|
|
63
65
|
* Available state properties:
|
|
64
|
-
* - `
|
|
65
|
-
* - `
|
|
66
|
-
* - `
|
|
66
|
+
* - `executionTimes`: Timestamps of executions tracked for the current window
|
|
67
|
+
* - `isExceeded`: Whether the rate limit has been reached
|
|
68
|
+
* - `settleCount`: Number of function executions that have completed (success or error)
|
|
69
|
+
* - `errorCount`: Number of function executions that have resulted in errors
|
|
67
70
|
* - `isExecuting`: Whether an async function execution is currently in progress
|
|
68
|
-
* - `lastError`: The error from the most recent failed execution (if any)
|
|
69
71
|
* - `lastResult`: The result from the most recent successful execution
|
|
70
|
-
* - `nextWindowTime`: Timestamp when the next window begins
|
|
71
72
|
* - `rejectionCount`: Number of function calls that were rejected due to rate limiting
|
|
72
|
-
* - `remainingInWindow`: Number of executions remaining in the current window
|
|
73
73
|
*
|
|
74
74
|
* ## Unmount behavior
|
|
75
75
|
*
|
|
@@ -189,5 +189,4 @@ function createAsyncRateLimiter(fn, options, selector = () => ({})) {
|
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
//#endregion
|
|
192
|
-
export { createAsyncRateLimiter };
|
|
193
|
-
//# sourceMappingURL=createAsyncRateLimiter.js.map
|
|
192
|
+
export { createAsyncRateLimiter };
|
|
@@ -2,16 +2,15 @@ import { Accessor, JSX } from "solid-js";
|
|
|
2
2
|
import { Store } from "@tanstack/solid-store";
|
|
3
3
|
import { AsyncThrottler, AsyncThrottlerOptions, AsyncThrottlerState } from "@tanstack/pacer/async-throttler";
|
|
4
4
|
import { AnyAsyncFunction } from "@tanstack/pacer/types";
|
|
5
|
-
|
|
6
5
|
//#region src/async-throttler/createAsyncThrottler.d.ts
|
|
7
|
-
interface SolidAsyncThrottlerOptions<TFn extends AnyAsyncFunction, TSelected = {}> extends AsyncThrottlerOptions<TFn> {
|
|
6
|
+
export interface SolidAsyncThrottlerOptions<TFn extends AnyAsyncFunction, TSelected = {}> extends AsyncThrottlerOptions<TFn> {
|
|
8
7
|
/**
|
|
9
8
|
* Optional callback invoked when the owning component unmounts. Receives the throttler instance.
|
|
10
9
|
* When provided, replaces the default cleanup (cancel + abort); use it to call flush(), reset(), cancel(), add logging, etc.
|
|
11
10
|
*/
|
|
12
11
|
onUnmount?: (throttler: SolidAsyncThrottler<TFn, TSelected>) => void;
|
|
13
12
|
}
|
|
14
|
-
interface SolidAsyncThrottler<TFn extends AnyAsyncFunction, TSelected = {}> extends Omit<AsyncThrottler<TFn>, 'store'> {
|
|
13
|
+
export interface SolidAsyncThrottler<TFn extends AnyAsyncFunction, TSelected = {}> extends Omit<AsyncThrottler<TFn>, 'store'> {
|
|
15
14
|
/**
|
|
16
15
|
* A Solid component that allows you to subscribe to the throttler state.
|
|
17
16
|
*
|
|
@@ -85,18 +84,15 @@ interface SolidAsyncThrottler<TFn extends AnyAsyncFunction, TSelected = {}> exte
|
|
|
85
84
|
* updates and gives you full control over when your component tracks state changes.
|
|
86
85
|
*
|
|
87
86
|
* Available state properties:
|
|
88
|
-
* - `
|
|
89
|
-
* - `
|
|
90
|
-
* - `executionCount`: Number of function executions that have been completed
|
|
91
|
-
* - `hasError`: Whether the last execution resulted in an error
|
|
87
|
+
* - `settleCount`: Number of function executions that have completed (success or error)
|
|
88
|
+
* - `errorCount`: Number of function executions that have resulted in errors
|
|
92
89
|
* - `isPending`: Whether the throttler is waiting for the timeout to trigger execution
|
|
93
90
|
* - `isExecuting`: Whether an async function execution is currently in progress
|
|
94
91
|
* - `lastArgs`: The arguments from the most recent call to maybeExecute
|
|
95
|
-
* - `lastError`: The error from the most recent failed execution (if any)
|
|
96
92
|
* - `lastExecutionTime`: Timestamp of the last execution
|
|
97
93
|
* - `lastResult`: The result from the most recent successful execution
|
|
98
94
|
* - `nextExecutionTime`: Timestamp of the next allowed execution
|
|
99
|
-
* - `status`: Current execution status ('disabled' | 'idle' | 'pending' | 'executing')
|
|
95
|
+
* - `status`: Current execution status ('disabled' | 'idle' | 'pending' | 'executing' | 'settled')
|
|
100
96
|
*
|
|
101
97
|
* ## Unmount behavior
|
|
102
98
|
*
|
|
@@ -151,14 +147,12 @@ interface SolidAsyncThrottler<TFn extends AnyAsyncFunction, TSelected = {}> exte
|
|
|
151
147
|
* console.error('API call failed:', error);
|
|
152
148
|
* }
|
|
153
149
|
* },
|
|
154
|
-
* (state) => ({
|
|
150
|
+
* (state) => ({ errorCount: state.errorCount })
|
|
155
151
|
* );
|
|
156
152
|
*
|
|
157
153
|
* // Access the selected state (will be empty object {} unless selector provided)
|
|
158
154
|
* const { isPending, isExecuting } = throttler.state();
|
|
159
155
|
* ```
|
|
160
156
|
*/
|
|
161
|
-
declare function createAsyncThrottler<TFn extends AnyAsyncFunction, TSelected = {}>(fn: TFn, options: SolidAsyncThrottlerOptions<TFn, TSelected>, selector?: (state: AsyncThrottlerState<TFn>) => TSelected): SolidAsyncThrottler<TFn, TSelected>;
|
|
162
|
-
//#endregion
|
|
163
|
-
export { SolidAsyncThrottler, SolidAsyncThrottlerOptions, createAsyncThrottler };
|
|
164
|
-
//# sourceMappingURL=createAsyncThrottler.d.ts.map
|
|
157
|
+
export declare function createAsyncThrottler<TFn extends AnyAsyncFunction, TSelected = {}>(fn: TFn, options: SolidAsyncThrottlerOptions<TFn, TSelected>, selector?: (state: AsyncThrottlerState<TFn>) => TSelected): SolidAsyncThrottler<TFn, TSelected>;
|
|
158
|
+
//#endregion
|
|
@@ -47,18 +47,15 @@ import { AsyncThrottler } from "@tanstack/pacer/async-throttler";
|
|
|
47
47
|
* updates and gives you full control over when your component tracks state changes.
|
|
48
48
|
*
|
|
49
49
|
* Available state properties:
|
|
50
|
-
* - `
|
|
51
|
-
* - `
|
|
52
|
-
* - `executionCount`: Number of function executions that have been completed
|
|
53
|
-
* - `hasError`: Whether the last execution resulted in an error
|
|
50
|
+
* - `settleCount`: Number of function executions that have completed (success or error)
|
|
51
|
+
* - `errorCount`: Number of function executions that have resulted in errors
|
|
54
52
|
* - `isPending`: Whether the throttler is waiting for the timeout to trigger execution
|
|
55
53
|
* - `isExecuting`: Whether an async function execution is currently in progress
|
|
56
54
|
* - `lastArgs`: The arguments from the most recent call to maybeExecute
|
|
57
|
-
* - `lastError`: The error from the most recent failed execution (if any)
|
|
58
55
|
* - `lastExecutionTime`: Timestamp of the last execution
|
|
59
56
|
* - `lastResult`: The result from the most recent successful execution
|
|
60
57
|
* - `nextExecutionTime`: Timestamp of the next allowed execution
|
|
61
|
-
* - `status`: Current execution status ('disabled' | 'idle' | 'pending' | 'executing')
|
|
58
|
+
* - `status`: Current execution status ('disabled' | 'idle' | 'pending' | 'executing' | 'settled')
|
|
62
59
|
*
|
|
63
60
|
* ## Unmount behavior
|
|
64
61
|
*
|
|
@@ -113,7 +110,7 @@ import { AsyncThrottler } from "@tanstack/pacer/async-throttler";
|
|
|
113
110
|
* console.error('API call failed:', error);
|
|
114
111
|
* }
|
|
115
112
|
* },
|
|
116
|
-
* (state) => ({
|
|
113
|
+
* (state) => ({ errorCount: state.errorCount })
|
|
117
114
|
* );
|
|
118
115
|
*
|
|
119
116
|
* // Access the selected state (will be empty object {} unless selector provided)
|
|
@@ -147,5 +144,4 @@ function createAsyncThrottler(fn, options, selector = () => ({})) {
|
|
|
147
144
|
}
|
|
148
145
|
|
|
149
146
|
//#endregion
|
|
150
|
-
export { createAsyncThrottler };
|
|
151
|
-
//# sourceMappingURL=createAsyncThrottler.js.map
|
|
147
|
+
export { createAsyncThrottler };
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { Accessor, JSX } from "solid-js";
|
|
2
2
|
import { Store } from "@tanstack/solid-store";
|
|
3
3
|
import { Batcher, BatcherOptions, BatcherState } from "@tanstack/pacer/batcher";
|
|
4
|
-
|
|
5
4
|
//#region src/batcher/createBatcher.d.ts
|
|
6
|
-
interface SolidBatcherOptions<TValue, TSelected = {}> extends BatcherOptions<TValue> {
|
|
5
|
+
export interface SolidBatcherOptions<TValue, TSelected = {}> extends BatcherOptions<TValue> {
|
|
7
6
|
/**
|
|
8
7
|
* Optional callback invoked when the owning component unmounts. Receives the batcher instance.
|
|
9
8
|
* When provided, replaces the default cleanup (cancel); use it to call flush(), reset(), cancel(), add logging, etc.
|
|
10
9
|
*/
|
|
11
10
|
onUnmount?: (batcher: SolidBatcher<TValue, TSelected>) => void;
|
|
12
11
|
}
|
|
13
|
-
interface SolidBatcher<TValue, TSelected = {}> extends Omit<Batcher<TValue>, 'store'> {
|
|
12
|
+
export interface SolidBatcher<TValue, TSelected = {}> extends Omit<Batcher<TValue>, 'store'> {
|
|
14
13
|
/**
|
|
15
14
|
* A Solid component that allows you to subscribe to the batcher state.
|
|
16
15
|
*
|
|
@@ -18,9 +17,9 @@ interface SolidBatcher<TValue, TSelected = {}> extends Omit<Batcher<TValue>, 'st
|
|
|
18
17
|
* deep in your component tree without needing to pass a selector to the hook.
|
|
19
18
|
*
|
|
20
19
|
* @example
|
|
21
|
-
* <batcher.Subscribe selector={(state) => ({ size: state.size,
|
|
20
|
+
* <batcher.Subscribe selector={(state) => ({ size: state.size, isPending: state.isPending })}>
|
|
22
21
|
* {(state) => (
|
|
23
|
-
* <div>Batch: {state().size} items, {state().
|
|
22
|
+
* <div>Batch: {state().size} items, {state().isPending ? 'Pending' : 'Idle'}</div>
|
|
24
23
|
* )}
|
|
25
24
|
* </batcher.Subscribe>
|
|
26
25
|
*/
|
|
@@ -79,7 +78,6 @@ interface SolidBatcher<TValue, TSelected = {}> extends Omit<Batcher<TValue>, 'st
|
|
|
79
78
|
*
|
|
80
79
|
* Available state properties:
|
|
81
80
|
* - `executionCount`: Number of batch executions that have been completed
|
|
82
|
-
* - `isRunning`: Whether the batcher is currently running (not stopped)
|
|
83
81
|
* - `items`: Array of items currently queued for batching
|
|
84
82
|
* - `totalItemsProcessed`: Total number of individual items that have been processed across all batches
|
|
85
83
|
*
|
|
@@ -112,11 +110,11 @@ interface SolidBatcher<TValue, TSelected = {}> extends Omit<Batcher<TValue>, 'st
|
|
|
112
110
|
* }
|
|
113
111
|
* );
|
|
114
112
|
*
|
|
115
|
-
* // Opt-in to track items or
|
|
113
|
+
* // Opt-in to track items or isPending changes (optimized for UI updates)
|
|
116
114
|
* const batcher = createBatcher(
|
|
117
115
|
* (items) => console.log('Processing batch:', items),
|
|
118
116
|
* { maxSize: 5, wait: 2000 },
|
|
119
|
-
* (state) => ({ items: state.items,
|
|
117
|
+
* (state) => ({ items: state.items, isPending: state.isPending })
|
|
120
118
|
* );
|
|
121
119
|
*
|
|
122
120
|
* // Opt-in to track execution metrics changes (optimized for tracking progress)
|
|
@@ -134,14 +132,12 @@ interface SolidBatcher<TValue, TSelected = {}> extends Omit<Batcher<TValue>, 'st
|
|
|
134
132
|
* batcher.addItem('task2');
|
|
135
133
|
*
|
|
136
134
|
* // Control the batcher
|
|
137
|
-
* batcher.
|
|
138
|
-
* batcher.
|
|
135
|
+
* batcher.cancel(); // Cancel the pending timer; queued items are retained
|
|
136
|
+
* batcher.flush(); // Process queued items immediately
|
|
139
137
|
*
|
|
140
138
|
* // Access the selected state (will be empty object {} unless selector provided)
|
|
141
|
-
* const { items,
|
|
139
|
+
* const { items, isPending } = batcher.state();
|
|
142
140
|
* ```
|
|
143
141
|
*/
|
|
144
|
-
declare function createBatcher<TValue, TSelected = {}>(fn: (items: Array<TValue>) => void, options?: SolidBatcherOptions<TValue, TSelected>, selector?: (state: BatcherState<TValue>) => TSelected): SolidBatcher<TValue, TSelected>;
|
|
145
|
-
//#endregion
|
|
146
|
-
export { SolidBatcher, SolidBatcherOptions, createBatcher };
|
|
147
|
-
//# sourceMappingURL=createBatcher.d.ts.map
|
|
142
|
+
export declare function createBatcher<TValue, TSelected = {}>(fn: (items: Array<TValue>) => void, options?: SolidBatcherOptions<TValue, TSelected>, selector?: (state: BatcherState<TValue>) => TSelected): SolidBatcher<TValue, TSelected>;
|
|
143
|
+
//#endregion
|
|
@@ -42,7 +42,6 @@ import { Batcher } from "@tanstack/pacer/batcher";
|
|
|
42
42
|
*
|
|
43
43
|
* Available state properties:
|
|
44
44
|
* - `executionCount`: Number of batch executions that have been completed
|
|
45
|
-
* - `isRunning`: Whether the batcher is currently running (not stopped)
|
|
46
45
|
* - `items`: Array of items currently queued for batching
|
|
47
46
|
* - `totalItemsProcessed`: Total number of individual items that have been processed across all batches
|
|
48
47
|
*
|
|
@@ -75,11 +74,11 @@ import { Batcher } from "@tanstack/pacer/batcher";
|
|
|
75
74
|
* }
|
|
76
75
|
* );
|
|
77
76
|
*
|
|
78
|
-
* // Opt-in to track items or
|
|
77
|
+
* // Opt-in to track items or isPending changes (optimized for UI updates)
|
|
79
78
|
* const batcher = createBatcher(
|
|
80
79
|
* (items) => console.log('Processing batch:', items),
|
|
81
80
|
* { maxSize: 5, wait: 2000 },
|
|
82
|
-
* (state) => ({ items: state.items,
|
|
81
|
+
* (state) => ({ items: state.items, isPending: state.isPending })
|
|
83
82
|
* );
|
|
84
83
|
*
|
|
85
84
|
* // Opt-in to track execution metrics changes (optimized for tracking progress)
|
|
@@ -97,11 +96,11 @@ import { Batcher } from "@tanstack/pacer/batcher";
|
|
|
97
96
|
* batcher.addItem('task2');
|
|
98
97
|
*
|
|
99
98
|
* // Control the batcher
|
|
100
|
-
* batcher.
|
|
101
|
-
* batcher.
|
|
99
|
+
* batcher.cancel(); // Cancel the pending timer; queued items are retained
|
|
100
|
+
* batcher.flush(); // Process queued items immediately
|
|
102
101
|
*
|
|
103
102
|
* // Access the selected state (will be empty object {} unless selector provided)
|
|
104
|
-
* const { items,
|
|
103
|
+
* const { items, isPending } = batcher.state();
|
|
105
104
|
* ```
|
|
106
105
|
*/
|
|
107
106
|
function createBatcher(fn, options = {}, selector = () => ({})) {
|
|
@@ -128,5 +127,4 @@ function createBatcher(fn, options = {}, selector = () => ({})) {
|
|
|
128
127
|
}
|
|
129
128
|
|
|
130
129
|
//#endregion
|
|
131
|
-
export { createBatcher };
|
|
132
|
-
//# sourceMappingURL=createBatcher.js.map
|
|
130
|
+
export { createBatcher };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { SolidDebouncer, SolidDebouncerOptions } from "./createDebouncer.js";
|
|
2
2
|
import { Accessor, Setter } from "solid-js";
|
|
3
3
|
import { DebouncerState } from "@tanstack/pacer/debouncer";
|
|
4
|
-
|
|
5
4
|
//#region src/debouncer/createDebouncedSignal.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* A Solid hook that creates a debounced state value, combining Solid's createSignal with debouncing functionality.
|
|
@@ -74,7 +73,5 @@ import { DebouncerState } from "@tanstack/pacer/debouncer";
|
|
|
74
73
|
* });
|
|
75
74
|
* ```
|
|
76
75
|
*/
|
|
77
|
-
declare function createDebouncedSignal<TValue, TSelected = {}>(value: TValue, initialOptions: SolidDebouncerOptions<Setter<TValue>, TSelected>, selector?: (state: DebouncerState<Setter<TValue>>) => TSelected): [Accessor<TValue>, Setter<TValue>, SolidDebouncer<Setter<TValue>, TSelected>];
|
|
78
|
-
//#endregion
|
|
79
|
-
export { createDebouncedSignal };
|
|
80
|
-
//# sourceMappingURL=createDebouncedSignal.d.ts.map
|
|
76
|
+
export declare function createDebouncedSignal<TValue, TSelected = {}>(value: TValue, initialOptions: SolidDebouncerOptions<Setter<TValue>, TSelected>, selector?: (state: DebouncerState<Setter<TValue>>) => TSelected): [Accessor<TValue>, Setter<TValue>, SolidDebouncer<Setter<TValue>, TSelected>];
|
|
77
|
+
//#endregion
|