@tanstack/solid-pacer 0.16.0 → 0.16.1
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/dist/async-batcher/createAsyncBatcher.cjs +122 -0
- package/dist/async-batcher/createAsyncBatcher.cjs.map +1 -0
- package/dist/{cjs/async-batcher → async-batcher}/createAsyncBatcher.d.cts +22 -17
- package/dist/{esm/async-batcher → async-batcher}/createAsyncBatcher.d.ts +22 -17
- package/dist/async-batcher/createAsyncBatcher.js +122 -0
- package/dist/async-batcher/createAsyncBatcher.js.map +1 -0
- package/dist/async-batcher/index.cjs +10 -0
- package/dist/async-batcher/index.d.cts +3 -0
- package/dist/async-batcher/index.d.ts +3 -0
- package/dist/async-batcher/index.js +5 -0
- package/dist/async-debouncer/createAsyncDebouncer.cjs +114 -0
- package/dist/async-debouncer/createAsyncDebouncer.cjs.map +1 -0
- package/dist/{cjs/async-debouncer → async-debouncer}/createAsyncDebouncer.d.cts +23 -18
- package/dist/{esm/async-debouncer → async-debouncer}/createAsyncDebouncer.d.ts +23 -18
- package/dist/async-debouncer/createAsyncDebouncer.js +114 -0
- package/dist/async-debouncer/createAsyncDebouncer.js.map +1 -0
- package/dist/async-debouncer/index.cjs +10 -0
- package/dist/async-debouncer/index.d.cts +3 -0
- package/dist/async-debouncer/index.d.ts +3 -0
- package/dist/async-debouncer/index.js +5 -0
- package/dist/async-queuer/createAsyncQueuer.cjs +114 -0
- package/dist/async-queuer/createAsyncQueuer.cjs.map +1 -0
- package/dist/{cjs/async-queuer → async-queuer}/createAsyncQueuer.d.cts +22 -17
- package/dist/{esm/async-queuer → async-queuer}/createAsyncQueuer.d.ts +22 -17
- package/dist/async-queuer/createAsyncQueuer.js +114 -0
- package/dist/async-queuer/createAsyncQueuer.js.map +1 -0
- package/dist/async-queuer/index.cjs +10 -0
- package/dist/async-queuer/index.d.cts +3 -0
- package/dist/async-queuer/index.d.ts +3 -0
- package/dist/async-queuer/index.js +5 -0
- package/dist/async-rate-limiter/createAsyncRateLimiter.cjs +120 -0
- package/dist/async-rate-limiter/createAsyncRateLimiter.cjs.map +1 -0
- package/dist/{cjs/async-rate-limiter → async-rate-limiter}/createAsyncRateLimiter.d.cts +23 -18
- package/dist/{esm/async-rate-limiter → async-rate-limiter}/createAsyncRateLimiter.d.ts +23 -18
- package/dist/async-rate-limiter/createAsyncRateLimiter.js +120 -0
- package/dist/async-rate-limiter/createAsyncRateLimiter.js.map +1 -0
- package/dist/async-rate-limiter/index.cjs +10 -0
- package/dist/async-rate-limiter/index.d.cts +3 -0
- package/dist/async-rate-limiter/index.d.ts +3 -0
- package/dist/async-rate-limiter/index.js +5 -0
- package/dist/async-throttler/createAsyncThrottler.cjs +108 -0
- package/dist/async-throttler/createAsyncThrottler.cjs.map +1 -0
- package/dist/{cjs/async-throttler → async-throttler}/createAsyncThrottler.d.cts +23 -18
- package/dist/{esm/async-throttler → async-throttler}/createAsyncThrottler.d.ts +23 -18
- package/dist/async-throttler/createAsyncThrottler.js +108 -0
- package/dist/async-throttler/createAsyncThrottler.js.map +1 -0
- package/dist/async-throttler/index.cjs +10 -0
- package/dist/async-throttler/index.d.cts +3 -0
- package/dist/async-throttler/index.d.ts +3 -0
- package/dist/async-throttler/index.js +5 -0
- package/dist/batcher/createBatcher.cjs +97 -0
- package/dist/batcher/createBatcher.cjs.map +1 -0
- package/dist/{cjs/batcher → batcher}/createBatcher.d.cts +22 -17
- package/dist/{esm/batcher → batcher}/createBatcher.d.ts +22 -17
- package/dist/batcher/createBatcher.js +97 -0
- package/dist/batcher/createBatcher.js.map +1 -0
- package/dist/batcher/index.cjs +10 -0
- package/dist/batcher/index.d.cts +3 -0
- package/dist/batcher/index.d.ts +3 -0
- package/dist/batcher/index.js +5 -0
- package/dist/debouncer/createDebouncedSignal.cjs +88 -0
- package/dist/debouncer/createDebouncedSignal.cjs.map +1 -0
- package/dist/{cjs/debouncer → debouncer}/createDebouncedSignal.d.cts +10 -8
- package/dist/{esm/debouncer → debouncer}/createDebouncedSignal.d.ts +10 -8
- package/dist/debouncer/createDebouncedSignal.js +88 -0
- package/dist/debouncer/createDebouncedSignal.js.map +1 -0
- package/dist/debouncer/createDebouncedValue.cjs +77 -0
- package/dist/debouncer/createDebouncedValue.cjs.map +1 -0
- package/dist/{cjs/debouncer → debouncer}/createDebouncedValue.d.cts +10 -4
- package/dist/{esm/debouncer → debouncer}/createDebouncedValue.d.ts +10 -4
- package/dist/debouncer/createDebouncedValue.js +77 -0
- package/dist/debouncer/createDebouncedValue.js.map +1 -0
- package/dist/debouncer/createDebouncer.cjs +101 -0
- package/dist/debouncer/createDebouncer.cjs.map +1 -0
- package/dist/{cjs/debouncer → debouncer}/createDebouncer.d.cts +23 -18
- package/dist/{esm/debouncer → debouncer}/createDebouncer.d.ts +23 -18
- package/dist/debouncer/createDebouncer.js +101 -0
- package/dist/debouncer/createDebouncer.js.map +1 -0
- package/dist/debouncer/index.cjs +14 -0
- package/dist/debouncer/index.d.cts +5 -0
- package/dist/debouncer/index.d.ts +5 -0
- package/dist/{esm/debouncer → debouncer}/index.js +5 -8
- package/dist/index.cjs +46 -0
- package/dist/index.d.cts +20 -0
- package/dist/index.d.ts +20 -0
- package/dist/{esm/index.js → index.js} +6 -26
- package/dist/provider/PacerProvider.cjs +27 -0
- package/dist/provider/PacerProvider.cjs.map +1 -0
- package/dist/provider/PacerProvider.d.cts +29 -0
- package/dist/provider/PacerProvider.d.ts +29 -0
- package/dist/provider/PacerProvider.js +25 -0
- package/dist/provider/PacerProvider.js.map +1 -0
- package/dist/provider/index.cjs +5 -0
- package/dist/provider/index.d.cts +2 -0
- package/dist/provider/index.d.ts +2 -0
- package/dist/provider/index.js +3 -0
- package/dist/queuer/createQueuedSignal.cjs +129 -0
- package/dist/queuer/createQueuedSignal.cjs.map +1 -0
- package/dist/{cjs/queuer → queuer}/createQueuedSignal.d.cts +9 -7
- package/dist/{esm/queuer → queuer}/createQueuedSignal.d.ts +9 -7
- package/dist/queuer/createQueuedSignal.js +129 -0
- package/dist/queuer/createQueuedSignal.js.map +1 -0
- package/dist/queuer/createQueuer.cjs +98 -0
- package/dist/queuer/createQueuer.cjs.map +1 -0
- package/dist/{cjs/queuer → queuer}/createQueuer.d.cts +22 -17
- package/dist/{esm/queuer → queuer}/createQueuer.d.ts +22 -17
- package/dist/queuer/createQueuer.js +98 -0
- package/dist/queuer/createQueuer.js.map +1 -0
- package/dist/queuer/index.cjs +12 -0
- package/dist/queuer/index.d.cts +4 -0
- package/dist/queuer/index.d.ts +4 -0
- package/dist/queuer/index.js +6 -0
- package/dist/rate-limiter/createRateLimitedSignal.cjs +102 -0
- package/dist/rate-limiter/createRateLimitedSignal.cjs.map +1 -0
- package/dist/{cjs/rate-limiter → rate-limiter}/createRateLimitedSignal.d.cts +10 -8
- package/dist/{esm/rate-limiter → rate-limiter}/createRateLimitedSignal.d.ts +10 -8
- package/dist/rate-limiter/createRateLimitedSignal.js +102 -0
- package/dist/rate-limiter/createRateLimitedSignal.js.map +1 -0
- package/dist/rate-limiter/createRateLimitedValue.cjs +102 -0
- package/dist/rate-limiter/createRateLimitedValue.cjs.map +1 -0
- package/dist/{cjs/rate-limiter → rate-limiter}/createRateLimitedValue.d.cts +10 -4
- package/dist/{esm/rate-limiter → rate-limiter}/createRateLimitedValue.d.ts +10 -4
- package/dist/rate-limiter/createRateLimitedValue.js +102 -0
- package/dist/rate-limiter/createRateLimitedValue.js.map +1 -0
- package/dist/rate-limiter/createRateLimiter.cjs +95 -0
- package/dist/rate-limiter/createRateLimiter.cjs.map +1 -0
- package/dist/{cjs/rate-limiter → rate-limiter}/createRateLimiter.d.cts +23 -18
- package/dist/{esm/rate-limiter → rate-limiter}/createRateLimiter.d.ts +23 -18
- package/dist/rate-limiter/createRateLimiter.js +95 -0
- package/dist/rate-limiter/createRateLimiter.js.map +1 -0
- package/dist/rate-limiter/index.cjs +14 -0
- package/dist/rate-limiter/index.d.cts +5 -0
- package/dist/rate-limiter/index.d.ts +5 -0
- package/dist/{esm/rate-limiter → rate-limiter}/index.js +4 -7
- package/dist/throttler/createThrottledSignal.cjs +79 -0
- package/dist/throttler/createThrottledSignal.cjs.map +1 -0
- package/dist/{cjs/throttler → throttler}/createThrottledSignal.d.cts +10 -8
- package/dist/{esm/throttler → throttler}/createThrottledSignal.d.ts +10 -8
- package/dist/throttler/createThrottledSignal.js +79 -0
- package/dist/throttler/createThrottledSignal.js.map +1 -0
- package/dist/throttler/createThrottledValue.cjs +74 -0
- package/dist/throttler/createThrottledValue.cjs.map +1 -0
- package/dist/{cjs/throttler → throttler}/createThrottledValue.d.cts +10 -4
- package/dist/{esm/throttler → throttler}/createThrottledValue.d.ts +10 -4
- package/dist/throttler/createThrottledValue.js +74 -0
- package/dist/throttler/createThrottledValue.js.map +1 -0
- package/dist/throttler/createThrottler.cjs +97 -0
- package/dist/throttler/createThrottler.cjs.map +1 -0
- package/dist/{cjs/throttler → throttler}/createThrottler.d.cts +23 -18
- package/dist/{esm/throttler → throttler}/createThrottler.d.ts +23 -18
- package/dist/throttler/createThrottler.js +97 -0
- package/dist/throttler/createThrottler.js.map +1 -0
- package/dist/throttler/index.cjs +14 -0
- package/dist/throttler/index.d.cts +5 -0
- package/dist/throttler/index.d.ts +5 -0
- package/dist/{esm/throttler → throttler}/index.js +5 -8
- package/dist/types/index.cjs +9 -0
- package/dist/types/index.d.cts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +3 -0
- package/dist/utils/index.cjs +9 -0
- package/dist/utils/index.d.cts +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +3 -0
- package/package.json +37 -106
- package/src/async-batcher/createAsyncBatcher.ts +4 -2
- package/src/async-queuer/createAsyncQueuer.ts +4 -2
- package/src/batcher/createBatcher.ts +4 -2
- package/src/debouncer/createDebouncer.ts +4 -2
- package/src/provider/index.ts +1 -0
- package/src/queuer/createQueuer.ts +4 -2
- package/src/rate-limiter/createRateLimiter.ts +4 -2
- package/src/throttler/createThrottler.ts +4 -2
- package/dist/cjs/async-batcher/createAsyncBatcher.cjs +0 -19
- package/dist/cjs/async-batcher/createAsyncBatcher.cjs.map +0 -1
- package/dist/cjs/async-batcher/index.cjs +0 -12
- package/dist/cjs/async-batcher/index.cjs.map +0 -1
- package/dist/cjs/async-batcher/index.d.cts +0 -2
- package/dist/cjs/async-debouncer/createAsyncDebouncer.cjs +0 -25
- package/dist/cjs/async-debouncer/createAsyncDebouncer.cjs.map +0 -1
- package/dist/cjs/async-debouncer/index.cjs +0 -12
- package/dist/cjs/async-debouncer/index.cjs.map +0 -1
- package/dist/cjs/async-debouncer/index.d.cts +0 -2
- package/dist/cjs/async-queuer/createAsyncQueuer.cjs +0 -19
- package/dist/cjs/async-queuer/createAsyncQueuer.cjs.map +0 -1
- package/dist/cjs/async-queuer/index.cjs +0 -12
- package/dist/cjs/async-queuer/index.cjs.map +0 -1
- package/dist/cjs/async-queuer/index.d.cts +0 -2
- package/dist/cjs/async-rate-limiter/createAsyncRateLimiter.cjs +0 -19
- package/dist/cjs/async-rate-limiter/createAsyncRateLimiter.cjs.map +0 -1
- package/dist/cjs/async-rate-limiter/index.cjs +0 -12
- package/dist/cjs/async-rate-limiter/index.cjs.map +0 -1
- package/dist/cjs/async-rate-limiter/index.d.cts +0 -2
- package/dist/cjs/async-throttler/createAsyncThrottler.cjs +0 -19
- package/dist/cjs/async-throttler/createAsyncThrottler.cjs.map +0 -1
- package/dist/cjs/async-throttler/index.cjs +0 -12
- package/dist/cjs/async-throttler/index.cjs.map +0 -1
- package/dist/cjs/async-throttler/index.d.cts +0 -2
- package/dist/cjs/batcher/createBatcher.cjs +0 -19
- package/dist/cjs/batcher/createBatcher.cjs.map +0 -1
- package/dist/cjs/batcher/index.cjs +0 -12
- package/dist/cjs/batcher/index.cjs.map +0 -1
- package/dist/cjs/batcher/index.d.cts +0 -2
- package/dist/cjs/debouncer/createDebouncedSignal.cjs +0 -11
- package/dist/cjs/debouncer/createDebouncedSignal.cjs.map +0 -1
- package/dist/cjs/debouncer/createDebouncedValue.cjs +0 -17
- package/dist/cjs/debouncer/createDebouncedValue.cjs.map +0 -1
- package/dist/cjs/debouncer/createDebouncer.cjs +0 -25
- package/dist/cjs/debouncer/createDebouncer.cjs.map +0 -1
- package/dist/cjs/debouncer/index.cjs +0 -16
- package/dist/cjs/debouncer/index.cjs.map +0 -1
- package/dist/cjs/debouncer/index.d.cts +0 -4
- package/dist/cjs/index.cjs +0 -48
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/index.d.cts +0 -22
- package/dist/cjs/provider/PacerProvider.cjs +0 -28
- package/dist/cjs/provider/PacerProvider.cjs.map +0 -1
- package/dist/cjs/provider/PacerProvider.d.cts +0 -25
- package/dist/cjs/queuer/createQueuedSignal.cjs +0 -9
- package/dist/cjs/queuer/createQueuedSignal.cjs.map +0 -1
- package/dist/cjs/queuer/createQueuer.cjs +0 -19
- package/dist/cjs/queuer/createQueuer.cjs.map +0 -1
- package/dist/cjs/queuer/index.cjs +0 -14
- package/dist/cjs/queuer/index.cjs.map +0 -1
- package/dist/cjs/queuer/index.d.cts +0 -3
- package/dist/cjs/rate-limiter/createRateLimitedSignal.cjs +0 -19
- package/dist/cjs/rate-limiter/createRateLimitedSignal.cjs.map +0 -1
- package/dist/cjs/rate-limiter/createRateLimitedValue.cjs +0 -13
- package/dist/cjs/rate-limiter/createRateLimitedValue.cjs.map +0 -1
- package/dist/cjs/rate-limiter/createRateLimiter.cjs +0 -19
- package/dist/cjs/rate-limiter/createRateLimiter.cjs.map +0 -1
- package/dist/cjs/rate-limiter/index.cjs +0 -16
- package/dist/cjs/rate-limiter/index.cjs.map +0 -1
- package/dist/cjs/rate-limiter/index.d.cts +0 -4
- package/dist/cjs/throttler/createThrottledSignal.cjs +0 -11
- package/dist/cjs/throttler/createThrottledSignal.cjs.map +0 -1
- package/dist/cjs/throttler/createThrottledValue.cjs +0 -17
- package/dist/cjs/throttler/createThrottledValue.cjs.map +0 -1
- package/dist/cjs/throttler/createThrottler.cjs +0 -25
- package/dist/cjs/throttler/createThrottler.cjs.map +0 -1
- package/dist/cjs/throttler/index.cjs +0 -16
- package/dist/cjs/throttler/index.cjs.map +0 -1
- package/dist/cjs/throttler/index.d.cts +0 -4
- package/dist/cjs/types/index.cjs +0 -10
- package/dist/cjs/types/index.cjs.map +0 -1
- package/dist/cjs/types/index.d.cts +0 -1
- package/dist/cjs/utils/index.cjs +0 -10
- package/dist/cjs/utils/index.cjs.map +0 -1
- package/dist/cjs/utils/index.d.cts +0 -1
- package/dist/esm/async-batcher/createAsyncBatcher.js +0 -19
- package/dist/esm/async-batcher/createAsyncBatcher.js.map +0 -1
- package/dist/esm/async-batcher/index.d.ts +0 -2
- package/dist/esm/async-batcher/index.js +0 -6
- package/dist/esm/async-batcher/index.js.map +0 -1
- package/dist/esm/async-debouncer/createAsyncDebouncer.js +0 -25
- package/dist/esm/async-debouncer/createAsyncDebouncer.js.map +0 -1
- package/dist/esm/async-debouncer/index.d.ts +0 -2
- package/dist/esm/async-debouncer/index.js +0 -6
- package/dist/esm/async-debouncer/index.js.map +0 -1
- package/dist/esm/async-queuer/createAsyncQueuer.js +0 -19
- package/dist/esm/async-queuer/createAsyncQueuer.js.map +0 -1
- package/dist/esm/async-queuer/index.d.ts +0 -2
- package/dist/esm/async-queuer/index.js +0 -6
- package/dist/esm/async-queuer/index.js.map +0 -1
- package/dist/esm/async-rate-limiter/createAsyncRateLimiter.js +0 -19
- package/dist/esm/async-rate-limiter/createAsyncRateLimiter.js.map +0 -1
- package/dist/esm/async-rate-limiter/index.d.ts +0 -2
- package/dist/esm/async-rate-limiter/index.js +0 -6
- package/dist/esm/async-rate-limiter/index.js.map +0 -1
- package/dist/esm/async-throttler/createAsyncThrottler.js +0 -19
- package/dist/esm/async-throttler/createAsyncThrottler.js.map +0 -1
- package/dist/esm/async-throttler/index.d.ts +0 -2
- package/dist/esm/async-throttler/index.js +0 -6
- package/dist/esm/async-throttler/index.js.map +0 -1
- package/dist/esm/batcher/createBatcher.js +0 -19
- package/dist/esm/batcher/createBatcher.js.map +0 -1
- package/dist/esm/batcher/index.d.ts +0 -2
- package/dist/esm/batcher/index.js +0 -6
- package/dist/esm/batcher/index.js.map +0 -1
- package/dist/esm/debouncer/createDebouncedSignal.js +0 -11
- package/dist/esm/debouncer/createDebouncedSignal.js.map +0 -1
- package/dist/esm/debouncer/createDebouncedValue.js +0 -17
- package/dist/esm/debouncer/createDebouncedValue.js.map +0 -1
- package/dist/esm/debouncer/createDebouncer.js +0 -25
- package/dist/esm/debouncer/createDebouncer.js.map +0 -1
- package/dist/esm/debouncer/index.d.ts +0 -4
- package/dist/esm/debouncer/index.js.map +0 -1
- package/dist/esm/index.d.ts +0 -22
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/provider/PacerProvider.d.ts +0 -25
- package/dist/esm/provider/PacerProvider.js +0 -28
- package/dist/esm/provider/PacerProvider.js.map +0 -1
- package/dist/esm/queuer/createQueuedSignal.js +0 -9
- package/dist/esm/queuer/createQueuedSignal.js.map +0 -1
- package/dist/esm/queuer/createQueuer.js +0 -19
- package/dist/esm/queuer/createQueuer.js.map +0 -1
- package/dist/esm/queuer/index.d.ts +0 -3
- package/dist/esm/queuer/index.js +0 -8
- package/dist/esm/queuer/index.js.map +0 -1
- package/dist/esm/rate-limiter/createRateLimitedSignal.js +0 -19
- package/dist/esm/rate-limiter/createRateLimitedSignal.js.map +0 -1
- package/dist/esm/rate-limiter/createRateLimitedValue.js +0 -13
- package/dist/esm/rate-limiter/createRateLimitedValue.js.map +0 -1
- package/dist/esm/rate-limiter/createRateLimiter.js +0 -19
- package/dist/esm/rate-limiter/createRateLimiter.js.map +0 -1
- package/dist/esm/rate-limiter/index.d.ts +0 -4
- package/dist/esm/rate-limiter/index.js.map +0 -1
- package/dist/esm/throttler/createThrottledSignal.js +0 -11
- package/dist/esm/throttler/createThrottledSignal.js.map +0 -1
- package/dist/esm/throttler/createThrottledValue.js +0 -17
- package/dist/esm/throttler/createThrottledValue.js.map +0 -1
- package/dist/esm/throttler/createThrottler.js +0 -25
- package/dist/esm/throttler/createThrottler.js.map +0 -1
- package/dist/esm/throttler/index.d.ts +0 -4
- package/dist/esm/throttler/index.js.map +0 -1
- package/dist/esm/types/index.d.ts +0 -1
- package/dist/esm/types/index.js +0 -2
- package/dist/esm/types/index.js.map +0 -1
- package/dist/esm/utils/index.d.ts +0 -1
- package/dist/esm/utils/index.js +0 -2
- package/dist/esm/utils/index.js.map +0 -1
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
const require_PacerProvider = require('../provider/PacerProvider.cjs');
|
|
2
|
+
let __tanstack_pacer_async_batcher = require("@tanstack/pacer/async-batcher");
|
|
3
|
+
let __tanstack_solid_store = require("@tanstack/solid-store");
|
|
4
|
+
|
|
5
|
+
//#region src/async-batcher/createAsyncBatcher.ts
|
|
6
|
+
/**
|
|
7
|
+
* Creates a Solid-compatible AsyncBatcher instance for managing asynchronous batches of items, exposing Solid signals for all stateful properties.
|
|
8
|
+
*
|
|
9
|
+
* This is the async version of the createBatcher hook. Unlike the sync version, this async batcher:
|
|
10
|
+
* - Handles promises and returns results from batch executions
|
|
11
|
+
* - Provides error handling with configurable error behavior
|
|
12
|
+
* - Tracks success, error, and settle counts separately
|
|
13
|
+
* - Has state tracking for when batches are executing
|
|
14
|
+
* - Returns the result of the batch function execution
|
|
15
|
+
*
|
|
16
|
+
* Features:
|
|
17
|
+
* - Configurable batch size and wait time
|
|
18
|
+
* - Custom batch processing logic via getShouldExecute
|
|
19
|
+
* - Event callbacks for monitoring batch operations
|
|
20
|
+
* - Error handling for failed batch operations
|
|
21
|
+
* - Automatic or manual batch processing
|
|
22
|
+
* - All stateful properties (items, counts, etc.) are exposed as Solid signals for reactivity
|
|
23
|
+
*
|
|
24
|
+
* The batcher collects items and processes them in batches based on:
|
|
25
|
+
* - Maximum batch size (number of items per batch)
|
|
26
|
+
* - Time-based batching (process after X milliseconds)
|
|
27
|
+
* - Custom batch processing logic via getShouldExecute
|
|
28
|
+
*
|
|
29
|
+
* Error Handling:
|
|
30
|
+
* - If an `onError` handler is provided, it will be called with the error and batcher instance
|
|
31
|
+
* - If `throwOnError` is true (default when no onError handler is provided), the error will be thrown
|
|
32
|
+
* - If `throwOnError` is false (default when onError handler is provided), the error will be swallowed
|
|
33
|
+
* - Both onError and throwOnError can be used together; the handler will be called before any error is thrown
|
|
34
|
+
* - The error state can be checked using the underlying AsyncBatcher instance
|
|
35
|
+
*
|
|
36
|
+
* ## State Management and Selector
|
|
37
|
+
*
|
|
38
|
+
* The hook uses TanStack Store for reactive state management. The `selector` parameter allows you
|
|
39
|
+
* to specify which state changes will trigger a re-render, optimizing performance by preventing
|
|
40
|
+
* unnecessary re-renders when irrelevant state changes occur.
|
|
41
|
+
*
|
|
42
|
+
* **By default, there will be no reactive state subscriptions** and you must opt-in to state
|
|
43
|
+
* tracking by providing a selector function. This prevents unnecessary re-renders and gives you
|
|
44
|
+
* full control over when your component updates. Only when you provide a selector will the
|
|
45
|
+
* component re-render when the selected state values change.
|
|
46
|
+
*
|
|
47
|
+
* Available state properties:
|
|
48
|
+
* - `errorCount`: Number of failed batch executions
|
|
49
|
+
* - `executionCount`: Total number of batch execution attempts (successful + failed)
|
|
50
|
+
* - `hasError`: Whether the last batch execution resulted in an error
|
|
51
|
+
* - `isExecuting`: Whether a batch execution is currently in progress
|
|
52
|
+
* - `items`: Array of items currently queued for batching
|
|
53
|
+
* - `lastError`: The error from the most recent failed batch execution (if any)
|
|
54
|
+
* - `lastResult`: The result from the most recent successful batch execution
|
|
55
|
+
* - `settleCount`: Number of batch executions that have completed (successful or failed)
|
|
56
|
+
* - `successCount`: Number of successful batch executions
|
|
57
|
+
*
|
|
58
|
+
* Example usage:
|
|
59
|
+
* ```tsx
|
|
60
|
+
* // Default behavior - no reactive state subscriptions
|
|
61
|
+
* const asyncBatcher = createAsyncBatcher(
|
|
62
|
+
* async (items) => {
|
|
63
|
+
* const results = await Promise.all(items.map(item => processItem(item)));
|
|
64
|
+
* return results;
|
|
65
|
+
* },
|
|
66
|
+
* {
|
|
67
|
+
* maxSize: 10,
|
|
68
|
+
* wait: 2000,
|
|
69
|
+
* onSuccess: (result) => {
|
|
70
|
+
* console.log('Batch processed successfully:', result);
|
|
71
|
+
* },
|
|
72
|
+
* onError: (error) => {
|
|
73
|
+
* console.error('Batch processing failed:', error);
|
|
74
|
+
* }
|
|
75
|
+
* }
|
|
76
|
+
* );
|
|
77
|
+
*
|
|
78
|
+
* // Opt-in to re-render when items or isExecuting changes (optimized for UI updates)
|
|
79
|
+
* const asyncBatcher = createAsyncBatcher(
|
|
80
|
+
* async (items) => {
|
|
81
|
+
* const results = await Promise.all(items.map(item => processItem(item)));
|
|
82
|
+
* return results;
|
|
83
|
+
* },
|
|
84
|
+
* { maxSize: 10, wait: 2000 },
|
|
85
|
+
* (state) => ({ items: state.items, isExecuting: state.isExecuting })
|
|
86
|
+
* );
|
|
87
|
+
*
|
|
88
|
+
* // Opt-in to re-render when error state changes (optimized for error handling)
|
|
89
|
+
* const asyncBatcher = createAsyncBatcher(
|
|
90
|
+
* async (items) => {
|
|
91
|
+
* const results = await Promise.all(items.map(item => processItem(item)));
|
|
92
|
+
* return results;
|
|
93
|
+
* },
|
|
94
|
+
* { maxSize: 10, wait: 2000 },
|
|
95
|
+
* (state) => ({ hasError: state.hasError, lastError: state.lastError })
|
|
96
|
+
* );
|
|
97
|
+
*
|
|
98
|
+
* // Add items to batch
|
|
99
|
+
* asyncBatcher.addItem(newItem);
|
|
100
|
+
*
|
|
101
|
+
* // Manually execute batch
|
|
102
|
+
* const result = await asyncBatcher.execute();
|
|
103
|
+
*
|
|
104
|
+
* // Access the selected state (will be empty object {} unless selector provided)
|
|
105
|
+
* const { items, isExecuting } = asyncBatcher.state();
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
function createAsyncBatcher(fn, options = {}, selector = () => ({})) {
|
|
109
|
+
const asyncBatcher = new __tanstack_pacer_async_batcher.AsyncBatcher(fn, {
|
|
110
|
+
...require_PacerProvider.useDefaultPacerOptions().asyncBatcher,
|
|
111
|
+
...options
|
|
112
|
+
});
|
|
113
|
+
const state = (0, __tanstack_solid_store.useStore)(asyncBatcher.store, selector);
|
|
114
|
+
return {
|
|
115
|
+
...asyncBatcher,
|
|
116
|
+
state
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
//#endregion
|
|
121
|
+
exports.createAsyncBatcher = createAsyncBatcher;
|
|
122
|
+
//# sourceMappingURL=createAsyncBatcher.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAsyncBatcher.cjs","names":["AsyncBatcher","useDefaultPacerOptions"],"sources":["../../src/async-batcher/createAsyncBatcher.ts"],"sourcesContent":["import { AsyncBatcher } from '@tanstack/pacer/async-batcher'\nimport { useStore } from '@tanstack/solid-store'\nimport { useDefaultPacerOptions } from '../provider/PacerProvider'\nimport type { Store } from '@tanstack/solid-store'\nimport type { Accessor } from 'solid-js'\nimport type {\n AsyncBatcherOptions,\n AsyncBatcherState,\n} from '@tanstack/pacer/async-batcher'\n\nexport interface SolidAsyncBatcher<TValue, TSelected = {}> extends Omit<\n AsyncBatcher<TValue>,\n 'store'\n> {\n /**\n * Reactive state that will be updated when the batcher state changes\n *\n * Use this instead of `batcher.store.state`\n */\n readonly state: Accessor<Readonly<TSelected>>\n /**\n * @deprecated Use `batcher.state` instead of `batcher.store.state` if you want to read reactive state.\n * The state on the store object is not reactive, as it has not been wrapped in a `useStore` hook internally.\n * Although, you can make the state reactive by using the `useStore` in your own usage.\n */\n readonly store: Store<Readonly<AsyncBatcherState<TValue>>>\n}\n\n/**\n * Creates a Solid-compatible AsyncBatcher instance for managing asynchronous batches of items, exposing Solid signals for all stateful properties.\n *\n * This is the async version of the createBatcher hook. Unlike the sync version, this async batcher:\n * - Handles promises and returns results from batch executions\n * - Provides error handling with configurable error behavior\n * - Tracks success, error, and settle counts separately\n * - Has state tracking for when batches are executing\n * - Returns the result of the batch function execution\n *\n * Features:\n * - Configurable batch size and wait time\n * - Custom batch processing logic via getShouldExecute\n * - Event callbacks for monitoring batch operations\n * - Error handling for failed batch operations\n * - Automatic or manual batch processing\n * - All stateful properties (items, counts, etc.) are exposed as Solid signals for reactivity\n *\n * The batcher collects items and processes them in batches based on:\n * - Maximum batch size (number of items per batch)\n * - Time-based batching (process after X milliseconds)\n * - Custom batch processing logic via getShouldExecute\n *\n * Error Handling:\n * - If an `onError` handler is provided, it will be called with the error and batcher instance\n * - If `throwOnError` is true (default when no onError handler is provided), the error will be thrown\n * - If `throwOnError` is false (default when onError handler is provided), the error will be swallowed\n * - Both onError and throwOnError can be used together; the handler will be called before any error is thrown\n * - The error state can be checked using the underlying AsyncBatcher instance\n *\n * ## State Management and Selector\n *\n * The hook uses TanStack Store for reactive state management. The `selector` parameter allows you\n * to specify which state changes will trigger a re-render, optimizing performance by preventing\n * unnecessary re-renders when irrelevant state changes occur.\n *\n * **By default, there will be no reactive state subscriptions** and you must opt-in to state\n * tracking by providing a selector function. This prevents unnecessary re-renders and gives you\n * full control over when your component updates. Only when you provide a selector will the\n * component re-render when the selected state values change.\n *\n * Available state properties:\n * - `errorCount`: Number of failed batch executions\n * - `executionCount`: Total number of batch execution attempts (successful + failed)\n * - `hasError`: Whether the last batch execution resulted in an error\n * - `isExecuting`: Whether a batch execution is currently in progress\n * - `items`: Array of items currently queued for batching\n * - `lastError`: The error from the most recent failed batch execution (if any)\n * - `lastResult`: The result from the most recent successful batch execution\n * - `settleCount`: Number of batch executions that have completed (successful or failed)\n * - `successCount`: Number of successful batch executions\n *\n * Example usage:\n * ```tsx\n * // Default behavior - no reactive state subscriptions\n * const asyncBatcher = createAsyncBatcher(\n * async (items) => {\n * const results = await Promise.all(items.map(item => processItem(item)));\n * return results;\n * },\n * {\n * maxSize: 10,\n * wait: 2000,\n * onSuccess: (result) => {\n * console.log('Batch processed successfully:', result);\n * },\n * onError: (error) => {\n * console.error('Batch processing failed:', error);\n * }\n * }\n * );\n *\n * // Opt-in to re-render when items or isExecuting changes (optimized for UI updates)\n * const asyncBatcher = createAsyncBatcher(\n * async (items) => {\n * const results = await Promise.all(items.map(item => processItem(item)));\n * return results;\n * },\n * { maxSize: 10, wait: 2000 },\n * (state) => ({ items: state.items, isExecuting: state.isExecuting })\n * );\n *\n * // Opt-in to re-render when error state changes (optimized for error handling)\n * const asyncBatcher = createAsyncBatcher(\n * async (items) => {\n * const results = await Promise.all(items.map(item => processItem(item)));\n * return results;\n * },\n * { maxSize: 10, wait: 2000 },\n * (state) => ({ hasError: state.hasError, lastError: state.lastError })\n * );\n *\n * // Add items to batch\n * asyncBatcher.addItem(newItem);\n *\n * // Manually execute batch\n * const result = await asyncBatcher.execute();\n *\n * // Access the selected state (will be empty object {} unless selector provided)\n * const { items, isExecuting } = asyncBatcher.state();\n * ```\n */\nexport function createAsyncBatcher<TValue, TSelected = {}>(\n fn: (items: Array<TValue>) => Promise<any>,\n options: AsyncBatcherOptions<TValue> = {},\n selector: (state: AsyncBatcherState<TValue>) => TSelected = () =>\n ({}) as TSelected,\n): SolidAsyncBatcher<TValue, TSelected> {\n const mergedOptions = {\n ...useDefaultPacerOptions().asyncBatcher,\n ...options,\n } as AsyncBatcherOptions<TValue>\n\n const asyncBatcher = new AsyncBatcher<TValue>(fn, mergedOptions)\n\n const state = useStore(asyncBatcher.store, selector)\n\n return {\n ...asyncBatcher,\n state,\n } as SolidAsyncBatcher<TValue, TSelected> // omit `store` in favor of `state`\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkIA,SAAgB,mBACd,IACA,UAAuC,EAAE,EACzC,kBACG,EAAE,GACiC;CAMtC,MAAM,eAAe,IAAIA,4CAAqB,IALxB;EACpB,GAAGC,8CAAwB,CAAC;EAC5B,GAAG;EACJ,CAE+D;CAEhE,MAAM,6CAAiB,aAAa,OAAO,SAAS;AAEpD,QAAO;EACL,GAAG;EACH;EACD"}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import { AsyncBatcher, AsyncBatcherOptions, AsyncBatcherState } from
|
|
2
|
-
import { Store } from
|
|
3
|
-
import { Accessor } from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { AsyncBatcher, AsyncBatcherOptions, AsyncBatcherState } from "@tanstack/pacer/async-batcher";
|
|
2
|
+
import { Store } from "@tanstack/solid-store";
|
|
3
|
+
import { Accessor } from "solid-js";
|
|
4
|
+
|
|
5
|
+
//#region src/async-batcher/createAsyncBatcher.d.ts
|
|
6
|
+
interface SolidAsyncBatcher<TValue, TSelected = {}> extends Omit<AsyncBatcher<TValue>, 'store'> {
|
|
7
|
+
/**
|
|
8
|
+
* Reactive state that will be updated when the batcher state changes
|
|
9
|
+
*
|
|
10
|
+
* Use this instead of `batcher.store.state`
|
|
11
|
+
*/
|
|
12
|
+
readonly state: Accessor<Readonly<TSelected>>;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Use `batcher.state` instead of `batcher.store.state` if you want to read reactive state.
|
|
15
|
+
* The state on the store object is not reactive, as it has not been wrapped in a `useStore` hook internally.
|
|
16
|
+
* Although, you can make the state reactive by using the `useStore` in your own usage.
|
|
17
|
+
*/
|
|
18
|
+
readonly store: Store<Readonly<AsyncBatcherState<TValue>>>;
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
19
21
|
* Creates a Solid-compatible AsyncBatcher instance for managing asynchronous batches of items, exposing Solid signals for all stateful properties.
|
|
@@ -117,4 +119,7 @@ export interface SolidAsyncBatcher<TValue, TSelected = {}> extends Omit<AsyncBat
|
|
|
117
119
|
* const { items, isExecuting } = asyncBatcher.state();
|
|
118
120
|
* ```
|
|
119
121
|
*/
|
|
120
|
-
|
|
122
|
+
declare function createAsyncBatcher<TValue, TSelected = {}>(fn: (items: Array<TValue>) => Promise<any>, options?: AsyncBatcherOptions<TValue>, selector?: (state: AsyncBatcherState<TValue>) => TSelected): SolidAsyncBatcher<TValue, TSelected>;
|
|
123
|
+
//#endregion
|
|
124
|
+
export { SolidAsyncBatcher, createAsyncBatcher };
|
|
125
|
+
//# sourceMappingURL=createAsyncBatcher.d.cts.map
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { Accessor } from "solid-js";
|
|
2
|
+
import { AsyncBatcher, AsyncBatcherOptions, AsyncBatcherState } from "@tanstack/pacer/async-batcher";
|
|
3
|
+
import { Store } from "@tanstack/solid-store";
|
|
4
|
+
|
|
5
|
+
//#region src/async-batcher/createAsyncBatcher.d.ts
|
|
6
|
+
interface SolidAsyncBatcher<TValue, TSelected = {}> extends Omit<AsyncBatcher<TValue>, 'store'> {
|
|
7
|
+
/**
|
|
8
|
+
* Reactive state that will be updated when the batcher state changes
|
|
9
|
+
*
|
|
10
|
+
* Use this instead of `batcher.store.state`
|
|
11
|
+
*/
|
|
12
|
+
readonly state: Accessor<Readonly<TSelected>>;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Use `batcher.state` instead of `batcher.store.state` if you want to read reactive state.
|
|
15
|
+
* The state on the store object is not reactive, as it has not been wrapped in a `useStore` hook internally.
|
|
16
|
+
* Although, you can make the state reactive by using the `useStore` in your own usage.
|
|
17
|
+
*/
|
|
18
|
+
readonly store: Store<Readonly<AsyncBatcherState<TValue>>>;
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
19
21
|
* Creates a Solid-compatible AsyncBatcher instance for managing asynchronous batches of items, exposing Solid signals for all stateful properties.
|
|
@@ -117,4 +119,7 @@ export interface SolidAsyncBatcher<TValue, TSelected = {}> extends Omit<AsyncBat
|
|
|
117
119
|
* const { items, isExecuting } = asyncBatcher.state();
|
|
118
120
|
* ```
|
|
119
121
|
*/
|
|
120
|
-
|
|
122
|
+
declare function createAsyncBatcher<TValue, TSelected = {}>(fn: (items: Array<TValue>) => Promise<any>, options?: AsyncBatcherOptions<TValue>, selector?: (state: AsyncBatcherState<TValue>) => TSelected): SolidAsyncBatcher<TValue, TSelected>;
|
|
123
|
+
//#endregion
|
|
124
|
+
export { SolidAsyncBatcher, createAsyncBatcher };
|
|
125
|
+
//# sourceMappingURL=createAsyncBatcher.d.ts.map
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { useDefaultPacerOptions } from "../provider/PacerProvider.js";
|
|
2
|
+
import { AsyncBatcher } from "@tanstack/pacer/async-batcher";
|
|
3
|
+
import { useStore } from "@tanstack/solid-store";
|
|
4
|
+
|
|
5
|
+
//#region src/async-batcher/createAsyncBatcher.ts
|
|
6
|
+
/**
|
|
7
|
+
* Creates a Solid-compatible AsyncBatcher instance for managing asynchronous batches of items, exposing Solid signals for all stateful properties.
|
|
8
|
+
*
|
|
9
|
+
* This is the async version of the createBatcher hook. Unlike the sync version, this async batcher:
|
|
10
|
+
* - Handles promises and returns results from batch executions
|
|
11
|
+
* - Provides error handling with configurable error behavior
|
|
12
|
+
* - Tracks success, error, and settle counts separately
|
|
13
|
+
* - Has state tracking for when batches are executing
|
|
14
|
+
* - Returns the result of the batch function execution
|
|
15
|
+
*
|
|
16
|
+
* Features:
|
|
17
|
+
* - Configurable batch size and wait time
|
|
18
|
+
* - Custom batch processing logic via getShouldExecute
|
|
19
|
+
* - Event callbacks for monitoring batch operations
|
|
20
|
+
* - Error handling for failed batch operations
|
|
21
|
+
* - Automatic or manual batch processing
|
|
22
|
+
* - All stateful properties (items, counts, etc.) are exposed as Solid signals for reactivity
|
|
23
|
+
*
|
|
24
|
+
* The batcher collects items and processes them in batches based on:
|
|
25
|
+
* - Maximum batch size (number of items per batch)
|
|
26
|
+
* - Time-based batching (process after X milliseconds)
|
|
27
|
+
* - Custom batch processing logic via getShouldExecute
|
|
28
|
+
*
|
|
29
|
+
* Error Handling:
|
|
30
|
+
* - If an `onError` handler is provided, it will be called with the error and batcher instance
|
|
31
|
+
* - If `throwOnError` is true (default when no onError handler is provided), the error will be thrown
|
|
32
|
+
* - If `throwOnError` is false (default when onError handler is provided), the error will be swallowed
|
|
33
|
+
* - Both onError and throwOnError can be used together; the handler will be called before any error is thrown
|
|
34
|
+
* - The error state can be checked using the underlying AsyncBatcher instance
|
|
35
|
+
*
|
|
36
|
+
* ## State Management and Selector
|
|
37
|
+
*
|
|
38
|
+
* The hook uses TanStack Store for reactive state management. The `selector` parameter allows you
|
|
39
|
+
* to specify which state changes will trigger a re-render, optimizing performance by preventing
|
|
40
|
+
* unnecessary re-renders when irrelevant state changes occur.
|
|
41
|
+
*
|
|
42
|
+
* **By default, there will be no reactive state subscriptions** and you must opt-in to state
|
|
43
|
+
* tracking by providing a selector function. This prevents unnecessary re-renders and gives you
|
|
44
|
+
* full control over when your component updates. Only when you provide a selector will the
|
|
45
|
+
* component re-render when the selected state values change.
|
|
46
|
+
*
|
|
47
|
+
* Available state properties:
|
|
48
|
+
* - `errorCount`: Number of failed batch executions
|
|
49
|
+
* - `executionCount`: Total number of batch execution attempts (successful + failed)
|
|
50
|
+
* - `hasError`: Whether the last batch execution resulted in an error
|
|
51
|
+
* - `isExecuting`: Whether a batch execution is currently in progress
|
|
52
|
+
* - `items`: Array of items currently queued for batching
|
|
53
|
+
* - `lastError`: The error from the most recent failed batch execution (if any)
|
|
54
|
+
* - `lastResult`: The result from the most recent successful batch execution
|
|
55
|
+
* - `settleCount`: Number of batch executions that have completed (successful or failed)
|
|
56
|
+
* - `successCount`: Number of successful batch executions
|
|
57
|
+
*
|
|
58
|
+
* Example usage:
|
|
59
|
+
* ```tsx
|
|
60
|
+
* // Default behavior - no reactive state subscriptions
|
|
61
|
+
* const asyncBatcher = createAsyncBatcher(
|
|
62
|
+
* async (items) => {
|
|
63
|
+
* const results = await Promise.all(items.map(item => processItem(item)));
|
|
64
|
+
* return results;
|
|
65
|
+
* },
|
|
66
|
+
* {
|
|
67
|
+
* maxSize: 10,
|
|
68
|
+
* wait: 2000,
|
|
69
|
+
* onSuccess: (result) => {
|
|
70
|
+
* console.log('Batch processed successfully:', result);
|
|
71
|
+
* },
|
|
72
|
+
* onError: (error) => {
|
|
73
|
+
* console.error('Batch processing failed:', error);
|
|
74
|
+
* }
|
|
75
|
+
* }
|
|
76
|
+
* );
|
|
77
|
+
*
|
|
78
|
+
* // Opt-in to re-render when items or isExecuting changes (optimized for UI updates)
|
|
79
|
+
* const asyncBatcher = createAsyncBatcher(
|
|
80
|
+
* async (items) => {
|
|
81
|
+
* const results = await Promise.all(items.map(item => processItem(item)));
|
|
82
|
+
* return results;
|
|
83
|
+
* },
|
|
84
|
+
* { maxSize: 10, wait: 2000 },
|
|
85
|
+
* (state) => ({ items: state.items, isExecuting: state.isExecuting })
|
|
86
|
+
* );
|
|
87
|
+
*
|
|
88
|
+
* // Opt-in to re-render when error state changes (optimized for error handling)
|
|
89
|
+
* const asyncBatcher = createAsyncBatcher(
|
|
90
|
+
* async (items) => {
|
|
91
|
+
* const results = await Promise.all(items.map(item => processItem(item)));
|
|
92
|
+
* return results;
|
|
93
|
+
* },
|
|
94
|
+
* { maxSize: 10, wait: 2000 },
|
|
95
|
+
* (state) => ({ hasError: state.hasError, lastError: state.lastError })
|
|
96
|
+
* );
|
|
97
|
+
*
|
|
98
|
+
* // Add items to batch
|
|
99
|
+
* asyncBatcher.addItem(newItem);
|
|
100
|
+
*
|
|
101
|
+
* // Manually execute batch
|
|
102
|
+
* const result = await asyncBatcher.execute();
|
|
103
|
+
*
|
|
104
|
+
* // Access the selected state (will be empty object {} unless selector provided)
|
|
105
|
+
* const { items, isExecuting } = asyncBatcher.state();
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
function createAsyncBatcher(fn, options = {}, selector = () => ({})) {
|
|
109
|
+
const asyncBatcher = new AsyncBatcher(fn, {
|
|
110
|
+
...useDefaultPacerOptions().asyncBatcher,
|
|
111
|
+
...options
|
|
112
|
+
});
|
|
113
|
+
const state = useStore(asyncBatcher.store, selector);
|
|
114
|
+
return {
|
|
115
|
+
...asyncBatcher,
|
|
116
|
+
state
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
//#endregion
|
|
121
|
+
export { createAsyncBatcher };
|
|
122
|
+
//# sourceMappingURL=createAsyncBatcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAsyncBatcher.js","names":[],"sources":["../../src/async-batcher/createAsyncBatcher.ts"],"sourcesContent":["import { AsyncBatcher } from '@tanstack/pacer/async-batcher'\nimport { useStore } from '@tanstack/solid-store'\nimport { useDefaultPacerOptions } from '../provider/PacerProvider'\nimport type { Store } from '@tanstack/solid-store'\nimport type { Accessor } from 'solid-js'\nimport type {\n AsyncBatcherOptions,\n AsyncBatcherState,\n} from '@tanstack/pacer/async-batcher'\n\nexport interface SolidAsyncBatcher<TValue, TSelected = {}> extends Omit<\n AsyncBatcher<TValue>,\n 'store'\n> {\n /**\n * Reactive state that will be updated when the batcher state changes\n *\n * Use this instead of `batcher.store.state`\n */\n readonly state: Accessor<Readonly<TSelected>>\n /**\n * @deprecated Use `batcher.state` instead of `batcher.store.state` if you want to read reactive state.\n * The state on the store object is not reactive, as it has not been wrapped in a `useStore` hook internally.\n * Although, you can make the state reactive by using the `useStore` in your own usage.\n */\n readonly store: Store<Readonly<AsyncBatcherState<TValue>>>\n}\n\n/**\n * Creates a Solid-compatible AsyncBatcher instance for managing asynchronous batches of items, exposing Solid signals for all stateful properties.\n *\n * This is the async version of the createBatcher hook. Unlike the sync version, this async batcher:\n * - Handles promises and returns results from batch executions\n * - Provides error handling with configurable error behavior\n * - Tracks success, error, and settle counts separately\n * - Has state tracking for when batches are executing\n * - Returns the result of the batch function execution\n *\n * Features:\n * - Configurable batch size and wait time\n * - Custom batch processing logic via getShouldExecute\n * - Event callbacks for monitoring batch operations\n * - Error handling for failed batch operations\n * - Automatic or manual batch processing\n * - All stateful properties (items, counts, etc.) are exposed as Solid signals for reactivity\n *\n * The batcher collects items and processes them in batches based on:\n * - Maximum batch size (number of items per batch)\n * - Time-based batching (process after X milliseconds)\n * - Custom batch processing logic via getShouldExecute\n *\n * Error Handling:\n * - If an `onError` handler is provided, it will be called with the error and batcher instance\n * - If `throwOnError` is true (default when no onError handler is provided), the error will be thrown\n * - If `throwOnError` is false (default when onError handler is provided), the error will be swallowed\n * - Both onError and throwOnError can be used together; the handler will be called before any error is thrown\n * - The error state can be checked using the underlying AsyncBatcher instance\n *\n * ## State Management and Selector\n *\n * The hook uses TanStack Store for reactive state management. The `selector` parameter allows you\n * to specify which state changes will trigger a re-render, optimizing performance by preventing\n * unnecessary re-renders when irrelevant state changes occur.\n *\n * **By default, there will be no reactive state subscriptions** and you must opt-in to state\n * tracking by providing a selector function. This prevents unnecessary re-renders and gives you\n * full control over when your component updates. Only when you provide a selector will the\n * component re-render when the selected state values change.\n *\n * Available state properties:\n * - `errorCount`: Number of failed batch executions\n * - `executionCount`: Total number of batch execution attempts (successful + failed)\n * - `hasError`: Whether the last batch execution resulted in an error\n * - `isExecuting`: Whether a batch execution is currently in progress\n * - `items`: Array of items currently queued for batching\n * - `lastError`: The error from the most recent failed batch execution (if any)\n * - `lastResult`: The result from the most recent successful batch execution\n * - `settleCount`: Number of batch executions that have completed (successful or failed)\n * - `successCount`: Number of successful batch executions\n *\n * Example usage:\n * ```tsx\n * // Default behavior - no reactive state subscriptions\n * const asyncBatcher = createAsyncBatcher(\n * async (items) => {\n * const results = await Promise.all(items.map(item => processItem(item)));\n * return results;\n * },\n * {\n * maxSize: 10,\n * wait: 2000,\n * onSuccess: (result) => {\n * console.log('Batch processed successfully:', result);\n * },\n * onError: (error) => {\n * console.error('Batch processing failed:', error);\n * }\n * }\n * );\n *\n * // Opt-in to re-render when items or isExecuting changes (optimized for UI updates)\n * const asyncBatcher = createAsyncBatcher(\n * async (items) => {\n * const results = await Promise.all(items.map(item => processItem(item)));\n * return results;\n * },\n * { maxSize: 10, wait: 2000 },\n * (state) => ({ items: state.items, isExecuting: state.isExecuting })\n * );\n *\n * // Opt-in to re-render when error state changes (optimized for error handling)\n * const asyncBatcher = createAsyncBatcher(\n * async (items) => {\n * const results = await Promise.all(items.map(item => processItem(item)));\n * return results;\n * },\n * { maxSize: 10, wait: 2000 },\n * (state) => ({ hasError: state.hasError, lastError: state.lastError })\n * );\n *\n * // Add items to batch\n * asyncBatcher.addItem(newItem);\n *\n * // Manually execute batch\n * const result = await asyncBatcher.execute();\n *\n * // Access the selected state (will be empty object {} unless selector provided)\n * const { items, isExecuting } = asyncBatcher.state();\n * ```\n */\nexport function createAsyncBatcher<TValue, TSelected = {}>(\n fn: (items: Array<TValue>) => Promise<any>,\n options: AsyncBatcherOptions<TValue> = {},\n selector: (state: AsyncBatcherState<TValue>) => TSelected = () =>\n ({}) as TSelected,\n): SolidAsyncBatcher<TValue, TSelected> {\n const mergedOptions = {\n ...useDefaultPacerOptions().asyncBatcher,\n ...options,\n } as AsyncBatcherOptions<TValue>\n\n const asyncBatcher = new AsyncBatcher<TValue>(fn, mergedOptions)\n\n const state = useStore(asyncBatcher.store, selector)\n\n return {\n ...asyncBatcher,\n state,\n } as SolidAsyncBatcher<TValue, TSelected> // omit `store` in favor of `state`\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkIA,SAAgB,mBACd,IACA,UAAuC,EAAE,EACzC,kBACG,EAAE,GACiC;CAMtC,MAAM,eAAe,IAAI,aAAqB,IALxB;EACpB,GAAG,wBAAwB,CAAC;EAC5B,GAAG;EACJ,CAE+D;CAEhE,MAAM,QAAQ,SAAS,aAAa,OAAO,SAAS;AAEpD,QAAO;EACL,GAAG;EACH;EACD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const require_createAsyncBatcher = require('./createAsyncBatcher.cjs');
|
|
2
|
+
|
|
3
|
+
exports.createAsyncBatcher = require_createAsyncBatcher.createAsyncBatcher;
|
|
4
|
+
var __tanstack_pacer_async_batcher = require("@tanstack/pacer/async-batcher");
|
|
5
|
+
Object.keys(__tanstack_pacer_async_batcher).forEach(function (k) {
|
|
6
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () { return __tanstack_pacer_async_batcher[k]; }
|
|
9
|
+
});
|
|
10
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
const require_PacerProvider = require('../provider/PacerProvider.cjs');
|
|
2
|
+
let solid_js = require("solid-js");
|
|
3
|
+
let __tanstack_solid_store = require("@tanstack/solid-store");
|
|
4
|
+
let __tanstack_pacer_async_debouncer = require("@tanstack/pacer/async-debouncer");
|
|
5
|
+
|
|
6
|
+
//#region src/async-debouncer/createAsyncDebouncer.ts
|
|
7
|
+
/**
|
|
8
|
+
* A low-level Solid hook that creates an `AsyncDebouncer` instance to delay execution of an async function.
|
|
9
|
+
*
|
|
10
|
+
* This hook is designed to be flexible and state-management agnostic - it simply returns a debouncer instance that
|
|
11
|
+
* you can integrate with any state management solution (createSignal, etc).
|
|
12
|
+
*
|
|
13
|
+
* Async debouncing ensures that an async function only executes after a specified delay has passed since its last invocation.
|
|
14
|
+
* Each new invocation resets the delay timer. This is useful for handling frequent events like window resizing
|
|
15
|
+
* or input changes where you only want to execute the handler after the events have stopped occurring.
|
|
16
|
+
*
|
|
17
|
+
* Unlike throttling which allows execution at regular intervals, debouncing prevents any execution until
|
|
18
|
+
* the function stops being called for the specified delay period.
|
|
19
|
+
*
|
|
20
|
+
* Unlike the non-async Debouncer, this async version supports returning values from the debounced function,
|
|
21
|
+
* making it ideal for API calls and other async operations where you want the result of the `maybeExecute` call
|
|
22
|
+
* instead of setting the result on a state variable from within the debounced function.
|
|
23
|
+
*
|
|
24
|
+
* Error Handling:
|
|
25
|
+
* - If an `onError` handler is provided, it will be called with the error and debouncer instance
|
|
26
|
+
* - If `throwOnError` is true (default when no onError handler is provided), the error will be thrown
|
|
27
|
+
* - If `throwOnError` is false (default when onError handler is provided), the error will be swallowed
|
|
28
|
+
* - Both onError and throwOnError can be used together - the handler will be called before any error is thrown
|
|
29
|
+
* - The error state can be checked using the underlying AsyncDebouncer instance
|
|
30
|
+
*
|
|
31
|
+
* ## State Management and Selector
|
|
32
|
+
*
|
|
33
|
+
* The hook uses TanStack Store for reactive state management. The `selector` parameter allows you
|
|
34
|
+
* to specify which state changes will trigger a re-render, optimizing performance by preventing
|
|
35
|
+
* unnecessary re-renders when irrelevant state changes occur.
|
|
36
|
+
*
|
|
37
|
+
* **By default, there will be no reactive state subscriptions** and you must opt-in to state
|
|
38
|
+
* tracking by providing a selector function. This prevents unnecessary re-renders and gives you
|
|
39
|
+
* full control over when your component updates. Only when you provide a selector will the
|
|
40
|
+
* component re-render when the selected state values change.
|
|
41
|
+
*
|
|
42
|
+
* Available state properties:
|
|
43
|
+
* - `canLeadingExecute`: Whether the debouncer can execute on the leading edge
|
|
44
|
+
* - `executionCount`: Number of function executions that have been completed
|
|
45
|
+
* - `hasError`: Whether the last execution resulted in an error
|
|
46
|
+
* - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution
|
|
47
|
+
* - `isExecuting`: Whether an async function execution is currently in progress
|
|
48
|
+
* - `lastArgs`: The arguments from the most recent call to maybeExecute
|
|
49
|
+
* - `lastError`: The error from the most recent failed execution (if any)
|
|
50
|
+
* - `lastResult`: The result from the most recent successful execution
|
|
51
|
+
* - `status`: Current execution status ('disabled' | 'idle' | 'pending' | 'executing')
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```tsx
|
|
55
|
+
* // Default behavior - no reactive state subscriptions
|
|
56
|
+
* const { maybeExecute } = createAsyncDebouncer(
|
|
57
|
+
* async (query: string) => {
|
|
58
|
+
* const results = await api.search(query);
|
|
59
|
+
* return results;
|
|
60
|
+
* },
|
|
61
|
+
* { wait: 500 }
|
|
62
|
+
* );
|
|
63
|
+
*
|
|
64
|
+
* // Opt-in to re-render when isPending or isExecuting changes (optimized for loading states)
|
|
65
|
+
* const debouncer = createAsyncDebouncer(
|
|
66
|
+
* async (query: string) => {
|
|
67
|
+
* const results = await api.search(query);
|
|
68
|
+
* return results;
|
|
69
|
+
* },
|
|
70
|
+
* { wait: 500 },
|
|
71
|
+
* (state) => ({ isPending: state.isPending, isExecuting: state.isExecuting })
|
|
72
|
+
* );
|
|
73
|
+
*
|
|
74
|
+
* // Opt-in to re-render when error state changes (optimized for error handling)
|
|
75
|
+
* const debouncer = createAsyncDebouncer(
|
|
76
|
+
* async (searchTerm) => {
|
|
77
|
+
* const data = await searchAPI(searchTerm);
|
|
78
|
+
* return data;
|
|
79
|
+
* },
|
|
80
|
+
* {
|
|
81
|
+
* wait: 300,
|
|
82
|
+
* leading: true, // Execute immediately on first call
|
|
83
|
+
* trailing: false, // Skip trailing edge updates
|
|
84
|
+
* onError: (error) => {
|
|
85
|
+
* console.error('API call failed:', error);
|
|
86
|
+
* }
|
|
87
|
+
* },
|
|
88
|
+
* (state) => ({ hasError: state.hasError, lastError: state.lastError })
|
|
89
|
+
* );
|
|
90
|
+
*
|
|
91
|
+
* // Access the selected state (will be empty object {} unless selector provided)
|
|
92
|
+
* const { isPending, isExecuting } = debouncer.state();
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
function createAsyncDebouncer(fn, options, selector = () => ({})) {
|
|
96
|
+
const asyncDebouncer = new __tanstack_pacer_async_debouncer.AsyncDebouncer(fn, {
|
|
97
|
+
...require_PacerProvider.useDefaultPacerOptions().asyncDebouncer,
|
|
98
|
+
...options
|
|
99
|
+
});
|
|
100
|
+
const state = (0, __tanstack_solid_store.useStore)(asyncDebouncer.store, selector);
|
|
101
|
+
(0, solid_js.createEffect)(() => {
|
|
102
|
+
(0, solid_js.onCleanup)(() => {
|
|
103
|
+
asyncDebouncer.cancel();
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
return {
|
|
107
|
+
...asyncDebouncer,
|
|
108
|
+
state
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
//#endregion
|
|
113
|
+
exports.createAsyncDebouncer = createAsyncDebouncer;
|
|
114
|
+
//# sourceMappingURL=createAsyncDebouncer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAsyncDebouncer.cjs","names":["AsyncDebouncer","useDefaultPacerOptions"],"sources":["../../src/async-debouncer/createAsyncDebouncer.ts"],"sourcesContent":["import { AsyncDebouncer } from '@tanstack/pacer/async-debouncer'\nimport { useStore } from '@tanstack/solid-store'\nimport { createEffect, onCleanup } from 'solid-js'\nimport { useDefaultPacerOptions } from '../provider/PacerProvider'\nimport type { Store } from '@tanstack/solid-store'\nimport type { Accessor } from 'solid-js'\nimport type {\n AsyncDebouncerOptions,\n AsyncDebouncerState,\n} from '@tanstack/pacer/async-debouncer'\nimport type { AnyAsyncFunction } from '@tanstack/pacer/types'\n\nexport interface SolidAsyncDebouncer<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n> extends Omit<AsyncDebouncer<TFn>, 'store'> {\n /**\n * Reactive state that will be updated when the debouncer state changes\n *\n * Use this instead of `debouncer.store.state`\n */\n readonly state: Accessor<Readonly<TSelected>>\n /**\n * @deprecated Use `debouncer.state` instead of `debouncer.store.state` if you want to read reactive state.\n * The state on the store object is not reactive, as it has not been wrapped in a `useStore` hook internally.\n * Although, you can make the state reactive by using the `useStore` in your own usage.\n */\n readonly store: Store<Readonly<AsyncDebouncerState<TFn>>>\n}\n\n/**\n * A low-level Solid hook that creates an `AsyncDebouncer` instance to delay execution of an async function.\n *\n * This hook is designed to be flexible and state-management agnostic - it simply returns a debouncer instance that\n * you can integrate with any state management solution (createSignal, etc).\n *\n * Async debouncing ensures that an async function only executes after a specified delay has passed since its last invocation.\n * Each new invocation resets the delay timer. This is useful for handling frequent events like window resizing\n * or input changes where you only want to execute the handler after the events have stopped occurring.\n *\n * Unlike throttling which allows execution at regular intervals, debouncing prevents any execution until\n * the function stops being called for the specified delay period.\n *\n * Unlike the non-async Debouncer, this async version supports returning values from the debounced function,\n * making it ideal for API calls and other async operations where you want the result of the `maybeExecute` call\n * instead of setting the result on a state variable from within the debounced function.\n *\n * Error Handling:\n * - If an `onError` handler is provided, it will be called with the error and debouncer instance\n * - If `throwOnError` is true (default when no onError handler is provided), the error will be thrown\n * - If `throwOnError` is false (default when onError handler is provided), the error will be swallowed\n * - Both onError and throwOnError can be used together - the handler will be called before any error is thrown\n * - The error state can be checked using the underlying AsyncDebouncer instance\n *\n * ## State Management and Selector\n *\n * The hook uses TanStack Store for reactive state management. The `selector` parameter allows you\n * to specify which state changes will trigger a re-render, optimizing performance by preventing\n * unnecessary re-renders when irrelevant state changes occur.\n *\n * **By default, there will be no reactive state subscriptions** and you must opt-in to state\n * tracking by providing a selector function. This prevents unnecessary re-renders and gives you\n * full control over when your component updates. Only when you provide a selector will the\n * component re-render when the selected state values change.\n *\n * Available state properties:\n * - `canLeadingExecute`: Whether the debouncer can execute on the leading edge\n * - `executionCount`: Number of function executions that have been completed\n * - `hasError`: Whether the last execution resulted in an error\n * - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution\n * - `isExecuting`: Whether an async function execution is currently in progress\n * - `lastArgs`: The arguments from the most recent call to maybeExecute\n * - `lastError`: The error from the most recent failed execution (if any)\n * - `lastResult`: The result from the most recent successful execution\n * - `status`: Current execution status ('disabled' | 'idle' | 'pending' | 'executing')\n *\n * @example\n * ```tsx\n * // Default behavior - no reactive state subscriptions\n * const { maybeExecute } = createAsyncDebouncer(\n * async (query: string) => {\n * const results = await api.search(query);\n * return results;\n * },\n * { wait: 500 }\n * );\n *\n * // Opt-in to re-render when isPending or isExecuting changes (optimized for loading states)\n * const debouncer = createAsyncDebouncer(\n * async (query: string) => {\n * const results = await api.search(query);\n * return results;\n * },\n * { wait: 500 },\n * (state) => ({ isPending: state.isPending, isExecuting: state.isExecuting })\n * );\n *\n * // Opt-in to re-render when error state changes (optimized for error handling)\n * const debouncer = createAsyncDebouncer(\n * async (searchTerm) => {\n * const data = await searchAPI(searchTerm);\n * return data;\n * },\n * {\n * wait: 300,\n * leading: true, // Execute immediately on first call\n * trailing: false, // Skip trailing edge updates\n * onError: (error) => {\n * console.error('API call failed:', error);\n * }\n * },\n * (state) => ({ hasError: state.hasError, lastError: state.lastError })\n * );\n *\n * // Access the selected state (will be empty object {} unless selector provided)\n * const { isPending, isExecuting } = debouncer.state();\n * ```\n */\nexport function createAsyncDebouncer<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n>(\n fn: TFn,\n options: AsyncDebouncerOptions<TFn>,\n selector: (state: AsyncDebouncerState<TFn>) => TSelected = () =>\n ({}) as TSelected,\n): SolidAsyncDebouncer<TFn, TSelected> {\n const mergedOptions = {\n ...useDefaultPacerOptions().asyncDebouncer,\n ...options,\n } as AsyncDebouncerOptions<TFn>\n\n const asyncDebouncer = new AsyncDebouncer<TFn>(fn, mergedOptions)\n\n const state = useStore(asyncDebouncer.store, selector)\n\n createEffect(() => {\n onCleanup(() => {\n asyncDebouncer.cancel()\n })\n })\n\n return {\n ...asyncDebouncer,\n state,\n } as SolidAsyncDebouncer<TFn, TSelected> // omit `store` in favor of `state`\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsHA,SAAgB,qBAId,IACA,SACA,kBACG,EAAE,GACgC;CAMrC,MAAM,iBAAiB,IAAIA,gDAAoB,IALzB;EACpB,GAAGC,8CAAwB,CAAC;EAC5B,GAAG;EACJ,CAEgE;CAEjE,MAAM,6CAAiB,eAAe,OAAO,SAAS;AAEtD,kCAAmB;AACjB,gCAAgB;AACd,kBAAe,QAAQ;IACvB;GACF;AAEF,QAAO;EACL,GAAG;EACH;EACD"}
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { AnyAsyncFunction } from
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { Store } from "@tanstack/solid-store";
|
|
2
|
+
import { Accessor } from "solid-js";
|
|
3
|
+
import { AsyncDebouncer, AsyncDebouncerOptions, AsyncDebouncerState } from "@tanstack/pacer/async-debouncer";
|
|
4
|
+
import { AnyAsyncFunction } from "@tanstack/pacer/types";
|
|
5
|
+
|
|
6
|
+
//#region src/async-debouncer/createAsyncDebouncer.d.ts
|
|
7
|
+
interface SolidAsyncDebouncer<TFn extends AnyAsyncFunction, TSelected = {}> extends Omit<AsyncDebouncer<TFn>, 'store'> {
|
|
8
|
+
/**
|
|
9
|
+
* Reactive state that will be updated when the debouncer state changes
|
|
10
|
+
*
|
|
11
|
+
* Use this instead of `debouncer.store.state`
|
|
12
|
+
*/
|
|
13
|
+
readonly state: Accessor<Readonly<TSelected>>;
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated Use `debouncer.state` instead of `debouncer.store.state` if you want to read reactive state.
|
|
16
|
+
* The state on the store object is not reactive, as it has not been wrapped in a `useStore` hook internally.
|
|
17
|
+
* Although, you can make the state reactive by using the `useStore` in your own usage.
|
|
18
|
+
*/
|
|
19
|
+
readonly store: Store<Readonly<AsyncDebouncerState<TFn>>>;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
22
|
* A low-level Solid hook that creates an `AsyncDebouncer` instance to delay execution of an async function.
|
|
@@ -104,4 +106,7 @@ export interface SolidAsyncDebouncer<TFn extends AnyAsyncFunction, TSelected = {
|
|
|
104
106
|
* const { isPending, isExecuting } = debouncer.state();
|
|
105
107
|
* ```
|
|
106
108
|
*/
|
|
107
|
-
|
|
109
|
+
declare function createAsyncDebouncer<TFn extends AnyAsyncFunction, TSelected = {}>(fn: TFn, options: AsyncDebouncerOptions<TFn>, selector?: (state: AsyncDebouncerState<TFn>) => TSelected): SolidAsyncDebouncer<TFn, TSelected>;
|
|
110
|
+
//#endregion
|
|
111
|
+
export { SolidAsyncDebouncer, createAsyncDebouncer };
|
|
112
|
+
//# sourceMappingURL=createAsyncDebouncer.d.cts.map
|