@tanstack/solid-pacer 0.16.0 → 0.17.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 +1 -1
- 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 @@
|
|
|
1
|
+
{"version":3,"file":"createDebouncedSignal.cjs","names":["createDebouncer"],"sources":["../../src/debouncer/createDebouncedSignal.ts"],"sourcesContent":["import { createSignal } from 'solid-js'\nimport { createDebouncer } from './createDebouncer'\nimport type { SolidDebouncer } from './createDebouncer'\nimport type { Accessor, Setter } from 'solid-js'\nimport type {\n DebouncerOptions,\n DebouncerState,\n} from '@tanstack/pacer/debouncer'\n\n/**\n * A Solid hook that creates a debounced state value, combining Solid's createSignal with debouncing functionality.\n * This hook provides both the current debounced value and methods to update it.\n *\n * The state value is only updated after the specified wait time has elapsed since the last update attempt.\n * If another update is attempted before the wait time expires, the timer resets and starts waiting again.\n * This is useful for handling frequent state updates that should be throttled, like search input values\n * or window resize dimensions.\n *\n * The hook returns a tuple containing:\n * - The current debounced value accessor\n * - A function to update the debounced value\n * - The debouncer instance with additional control methods and state signals\n *\n * ## State Management and Selector\n *\n * The hook uses TanStack Store for reactive state management via the underlying debouncer instance.\n * The `selector` parameter allows you to specify which debouncer state changes will trigger reactive updates,\n * optimizing performance by preventing unnecessary subscriptions 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 reactive updates and gives you\n * full control over when your component subscribes to state changes. Only when you provide a selector will\n * the reactive system track the selected state values.\n *\n * Available debouncer state properties:\n * - `canLeadingExecute`: Whether the debouncer can execute on the leading edge\n * - `executionCount`: Number of function executions that have been completed\n * - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution\n * - `lastArgs`: The arguments from the most recent call to maybeExecute\n * - `status`: Current execution status ('disabled' | 'idle' | 'pending')\n *\n * @example\n * ```tsx\n * // Default behavior - no reactive state subscriptions\n * const [searchTerm, setSearchTerm, debouncer] = createDebouncedSignal('', {\n * wait: 500 // Wait 500ms after last keystroke\n * });\n *\n * // Opt-in to reactive updates when pending state changes (optimized for loading indicators)\n * const [searchTerm, setSearchTerm, debouncer] = createDebouncedSignal(\n * '',\n * { wait: 500 },\n * (state) => ({ isPending: state.isPending })\n * );\n *\n * // Opt-in to reactive updates when execution count changes (optimized for tracking executions)\n * const [searchTerm, setSearchTerm, debouncer] = createDebouncedSignal(\n * '',\n * { wait: 500 },\n * (state) => ({ executionCount: state.executionCount })\n * );\n *\n * // Update value - will be debounced\n * const handleChange = (e) => {\n * setSearchTerm(e.target.value);\n * };\n *\n * // Access debouncer state via signals\n * console.log('Executions:', debouncer.state().executionCount);\n * console.log('Is pending:', debouncer.state().isPending);\n *\n * // In onExecute callback, use get* methods\n * const [searchTerm, setSearchTerm, debouncer] = createDebouncedSignal('', {\n * wait: 500,\n * onExecute: (debouncer) => {\n * console.log('Total executions:', debouncer.getExecutionCount());\n * }\n * });\n * ```\n */\nexport function createDebouncedSignal<TValue, TSelected = {}>(\n value: TValue,\n initialOptions: DebouncerOptions<Setter<TValue>>,\n selector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): [\n Accessor<TValue>,\n Setter<TValue>,\n SolidDebouncer<Setter<TValue>, TSelected>,\n] {\n const [debouncedValue, setDebouncedValue] = createSignal<TValue>(value)\n\n const debouncer = createDebouncer(setDebouncedValue, initialOptions, selector)\n\n return [debouncedValue, debouncer.maybeExecute as Setter<TValue>, debouncer]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgFA,SAAgB,sBACd,OACA,gBACA,UAKA;CACA,MAAM,CAAC,gBAAgB,gDAA0C,MAAM;CAEvE,MAAM,YAAYA,wCAAgB,mBAAmB,gBAAgB,SAAS;AAE9E,QAAO;EAAC;EAAgB,UAAU;EAAgC;EAAU"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { SolidDebouncer } from
|
|
2
|
-
import { Accessor, Setter } from
|
|
3
|
-
import { DebouncerOptions, DebouncerState } from
|
|
1
|
+
import { SolidDebouncer } from "./createDebouncer.cjs";
|
|
2
|
+
import { Accessor, Setter } from "solid-js";
|
|
3
|
+
import { DebouncerOptions, DebouncerState } from "@tanstack/pacer/debouncer";
|
|
4
|
+
|
|
5
|
+
//#region src/debouncer/createDebouncedSignal.d.ts
|
|
6
|
+
|
|
4
7
|
/**
|
|
5
8
|
* A Solid hook that creates a debounced state value, combining Solid's createSignal with debouncing functionality.
|
|
6
9
|
* This hook provides both the current debounced value and methods to update it.
|
|
@@ -72,8 +75,7 @@ import { DebouncerOptions, DebouncerState } from '@tanstack/pacer/debouncer';
|
|
|
72
75
|
* });
|
|
73
76
|
* ```
|
|
74
77
|
*/
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
];
|
|
78
|
+
declare function createDebouncedSignal<TValue, TSelected = {}>(value: TValue, initialOptions: DebouncerOptions<Setter<TValue>>, selector?: (state: DebouncerState<Setter<TValue>>) => TSelected): [Accessor<TValue>, Setter<TValue>, SolidDebouncer<Setter<TValue>, TSelected>];
|
|
79
|
+
//#endregion
|
|
80
|
+
export { createDebouncedSignal };
|
|
81
|
+
//# sourceMappingURL=createDebouncedSignal.d.cts.map
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { SolidDebouncer } from
|
|
2
|
-
import { Accessor, Setter } from
|
|
3
|
-
import { DebouncerOptions, DebouncerState } from
|
|
1
|
+
import { SolidDebouncer } from "./createDebouncer.js";
|
|
2
|
+
import { Accessor, Setter } from "solid-js";
|
|
3
|
+
import { DebouncerOptions, DebouncerState } from "@tanstack/pacer/debouncer";
|
|
4
|
+
|
|
5
|
+
//#region src/debouncer/createDebouncedSignal.d.ts
|
|
6
|
+
|
|
4
7
|
/**
|
|
5
8
|
* A Solid hook that creates a debounced state value, combining Solid's createSignal with debouncing functionality.
|
|
6
9
|
* This hook provides both the current debounced value and methods to update it.
|
|
@@ -72,8 +75,7 @@ import { DebouncerOptions, DebouncerState } from '@tanstack/pacer/debouncer';
|
|
|
72
75
|
* });
|
|
73
76
|
* ```
|
|
74
77
|
*/
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
];
|
|
78
|
+
declare function createDebouncedSignal<TValue, TSelected = {}>(value: TValue, initialOptions: DebouncerOptions<Setter<TValue>>, selector?: (state: DebouncerState<Setter<TValue>>) => TSelected): [Accessor<TValue>, Setter<TValue>, SolidDebouncer<Setter<TValue>, TSelected>];
|
|
79
|
+
//#endregion
|
|
80
|
+
export { createDebouncedSignal };
|
|
81
|
+
//# sourceMappingURL=createDebouncedSignal.d.ts.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { createDebouncer } from "./createDebouncer.js";
|
|
2
|
+
import { createSignal } from "solid-js";
|
|
3
|
+
|
|
4
|
+
//#region src/debouncer/createDebouncedSignal.ts
|
|
5
|
+
/**
|
|
6
|
+
* A Solid hook that creates a debounced state value, combining Solid's createSignal with debouncing functionality.
|
|
7
|
+
* This hook provides both the current debounced value and methods to update it.
|
|
8
|
+
*
|
|
9
|
+
* The state value is only updated after the specified wait time has elapsed since the last update attempt.
|
|
10
|
+
* If another update is attempted before the wait time expires, the timer resets and starts waiting again.
|
|
11
|
+
* This is useful for handling frequent state updates that should be throttled, like search input values
|
|
12
|
+
* or window resize dimensions.
|
|
13
|
+
*
|
|
14
|
+
* The hook returns a tuple containing:
|
|
15
|
+
* - The current debounced value accessor
|
|
16
|
+
* - A function to update the debounced value
|
|
17
|
+
* - The debouncer instance with additional control methods and state signals
|
|
18
|
+
*
|
|
19
|
+
* ## State Management and Selector
|
|
20
|
+
*
|
|
21
|
+
* The hook uses TanStack Store for reactive state management via the underlying debouncer instance.
|
|
22
|
+
* The `selector` parameter allows you to specify which debouncer state changes will trigger reactive updates,
|
|
23
|
+
* optimizing performance by preventing unnecessary subscriptions when irrelevant state changes occur.
|
|
24
|
+
*
|
|
25
|
+
* **By default, there will be no reactive state subscriptions** and you must opt-in to state
|
|
26
|
+
* tracking by providing a selector function. This prevents unnecessary reactive updates and gives you
|
|
27
|
+
* full control over when your component subscribes to state changes. Only when you provide a selector will
|
|
28
|
+
* the reactive system track the selected state values.
|
|
29
|
+
*
|
|
30
|
+
* Available debouncer state properties:
|
|
31
|
+
* - `canLeadingExecute`: Whether the debouncer can execute on the leading edge
|
|
32
|
+
* - `executionCount`: Number of function executions that have been completed
|
|
33
|
+
* - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution
|
|
34
|
+
* - `lastArgs`: The arguments from the most recent call to maybeExecute
|
|
35
|
+
* - `status`: Current execution status ('disabled' | 'idle' | 'pending')
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```tsx
|
|
39
|
+
* // Default behavior - no reactive state subscriptions
|
|
40
|
+
* const [searchTerm, setSearchTerm, debouncer] = createDebouncedSignal('', {
|
|
41
|
+
* wait: 500 // Wait 500ms after last keystroke
|
|
42
|
+
* });
|
|
43
|
+
*
|
|
44
|
+
* // Opt-in to reactive updates when pending state changes (optimized for loading indicators)
|
|
45
|
+
* const [searchTerm, setSearchTerm, debouncer] = createDebouncedSignal(
|
|
46
|
+
* '',
|
|
47
|
+
* { wait: 500 },
|
|
48
|
+
* (state) => ({ isPending: state.isPending })
|
|
49
|
+
* );
|
|
50
|
+
*
|
|
51
|
+
* // Opt-in to reactive updates when execution count changes (optimized for tracking executions)
|
|
52
|
+
* const [searchTerm, setSearchTerm, debouncer] = createDebouncedSignal(
|
|
53
|
+
* '',
|
|
54
|
+
* { wait: 500 },
|
|
55
|
+
* (state) => ({ executionCount: state.executionCount })
|
|
56
|
+
* );
|
|
57
|
+
*
|
|
58
|
+
* // Update value - will be debounced
|
|
59
|
+
* const handleChange = (e) => {
|
|
60
|
+
* setSearchTerm(e.target.value);
|
|
61
|
+
* };
|
|
62
|
+
*
|
|
63
|
+
* // Access debouncer state via signals
|
|
64
|
+
* console.log('Executions:', debouncer.state().executionCount);
|
|
65
|
+
* console.log('Is pending:', debouncer.state().isPending);
|
|
66
|
+
*
|
|
67
|
+
* // In onExecute callback, use get* methods
|
|
68
|
+
* const [searchTerm, setSearchTerm, debouncer] = createDebouncedSignal('', {
|
|
69
|
+
* wait: 500,
|
|
70
|
+
* onExecute: (debouncer) => {
|
|
71
|
+
* console.log('Total executions:', debouncer.getExecutionCount());
|
|
72
|
+
* }
|
|
73
|
+
* });
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
function createDebouncedSignal(value, initialOptions, selector) {
|
|
77
|
+
const [debouncedValue, setDebouncedValue] = createSignal(value);
|
|
78
|
+
const debouncer = createDebouncer(setDebouncedValue, initialOptions, selector);
|
|
79
|
+
return [
|
|
80
|
+
debouncedValue,
|
|
81
|
+
debouncer.maybeExecute,
|
|
82
|
+
debouncer
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
//#endregion
|
|
87
|
+
export { createDebouncedSignal };
|
|
88
|
+
//# sourceMappingURL=createDebouncedSignal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDebouncedSignal.js","names":[],"sources":["../../src/debouncer/createDebouncedSignal.ts"],"sourcesContent":["import { createSignal } from 'solid-js'\nimport { createDebouncer } from './createDebouncer'\nimport type { SolidDebouncer } from './createDebouncer'\nimport type { Accessor, Setter } from 'solid-js'\nimport type {\n DebouncerOptions,\n DebouncerState,\n} from '@tanstack/pacer/debouncer'\n\n/**\n * A Solid hook that creates a debounced state value, combining Solid's createSignal with debouncing functionality.\n * This hook provides both the current debounced value and methods to update it.\n *\n * The state value is only updated after the specified wait time has elapsed since the last update attempt.\n * If another update is attempted before the wait time expires, the timer resets and starts waiting again.\n * This is useful for handling frequent state updates that should be throttled, like search input values\n * or window resize dimensions.\n *\n * The hook returns a tuple containing:\n * - The current debounced value accessor\n * - A function to update the debounced value\n * - The debouncer instance with additional control methods and state signals\n *\n * ## State Management and Selector\n *\n * The hook uses TanStack Store for reactive state management via the underlying debouncer instance.\n * The `selector` parameter allows you to specify which debouncer state changes will trigger reactive updates,\n * optimizing performance by preventing unnecessary subscriptions 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 reactive updates and gives you\n * full control over when your component subscribes to state changes. Only when you provide a selector will\n * the reactive system track the selected state values.\n *\n * Available debouncer state properties:\n * - `canLeadingExecute`: Whether the debouncer can execute on the leading edge\n * - `executionCount`: Number of function executions that have been completed\n * - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution\n * - `lastArgs`: The arguments from the most recent call to maybeExecute\n * - `status`: Current execution status ('disabled' | 'idle' | 'pending')\n *\n * @example\n * ```tsx\n * // Default behavior - no reactive state subscriptions\n * const [searchTerm, setSearchTerm, debouncer] = createDebouncedSignal('', {\n * wait: 500 // Wait 500ms after last keystroke\n * });\n *\n * // Opt-in to reactive updates when pending state changes (optimized for loading indicators)\n * const [searchTerm, setSearchTerm, debouncer] = createDebouncedSignal(\n * '',\n * { wait: 500 },\n * (state) => ({ isPending: state.isPending })\n * );\n *\n * // Opt-in to reactive updates when execution count changes (optimized for tracking executions)\n * const [searchTerm, setSearchTerm, debouncer] = createDebouncedSignal(\n * '',\n * { wait: 500 },\n * (state) => ({ executionCount: state.executionCount })\n * );\n *\n * // Update value - will be debounced\n * const handleChange = (e) => {\n * setSearchTerm(e.target.value);\n * };\n *\n * // Access debouncer state via signals\n * console.log('Executions:', debouncer.state().executionCount);\n * console.log('Is pending:', debouncer.state().isPending);\n *\n * // In onExecute callback, use get* methods\n * const [searchTerm, setSearchTerm, debouncer] = createDebouncedSignal('', {\n * wait: 500,\n * onExecute: (debouncer) => {\n * console.log('Total executions:', debouncer.getExecutionCount());\n * }\n * });\n * ```\n */\nexport function createDebouncedSignal<TValue, TSelected = {}>(\n value: TValue,\n initialOptions: DebouncerOptions<Setter<TValue>>,\n selector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): [\n Accessor<TValue>,\n Setter<TValue>,\n SolidDebouncer<Setter<TValue>, TSelected>,\n] {\n const [debouncedValue, setDebouncedValue] = createSignal<TValue>(value)\n\n const debouncer = createDebouncer(setDebouncedValue, initialOptions, selector)\n\n return [debouncedValue, debouncer.maybeExecute as Setter<TValue>, debouncer]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgFA,SAAgB,sBACd,OACA,gBACA,UAKA;CACA,MAAM,CAAC,gBAAgB,qBAAqB,aAAqB,MAAM;CAEvE,MAAM,YAAY,gBAAgB,mBAAmB,gBAAgB,SAAS;AAE9E,QAAO;EAAC;EAAgB,UAAU;EAAgC;EAAU"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const require_createDebouncedSignal = require('./createDebouncedSignal.cjs');
|
|
2
|
+
let solid_js = require("solid-js");
|
|
3
|
+
|
|
4
|
+
//#region src/debouncer/createDebouncedValue.ts
|
|
5
|
+
/**
|
|
6
|
+
* A Solid hook that creates a debounced value that updates only after a specified delay.
|
|
7
|
+
* Unlike createDebouncedSignal, this hook automatically tracks changes to the input value
|
|
8
|
+
* and updates the debounced value accordingly.
|
|
9
|
+
*
|
|
10
|
+
* The debounced value will only update after the specified wait time has elapsed since
|
|
11
|
+
* the last change to the input value. If the input value changes again before the wait
|
|
12
|
+
* time expires, the timer resets and starts waiting again.
|
|
13
|
+
*
|
|
14
|
+
* This is useful for deriving debounced values from props or state that change frequently,
|
|
15
|
+
* like search queries or form inputs, where you want to limit how often downstream effects
|
|
16
|
+
* or calculations occur.
|
|
17
|
+
*
|
|
18
|
+
* The hook returns a tuple containing:
|
|
19
|
+
* - An Accessor that provides the current debounced value
|
|
20
|
+
* - The debouncer instance with control methods
|
|
21
|
+
*
|
|
22
|
+
* ## State Management and Selector
|
|
23
|
+
*
|
|
24
|
+
* The hook uses TanStack Store for reactive state management via the underlying debouncer instance.
|
|
25
|
+
* The `selector` parameter allows you to specify which debouncer state changes will trigger reactive updates,
|
|
26
|
+
* optimizing performance by preventing unnecessary subscriptions when irrelevant state changes occur.
|
|
27
|
+
*
|
|
28
|
+
* **By default, there will be no reactive state subscriptions** and you must opt-in to state
|
|
29
|
+
* tracking by providing a selector function. This prevents unnecessary reactive updates and gives you
|
|
30
|
+
* full control over when your component subscribes to state changes. Only when you provide a selector will
|
|
31
|
+
* the reactive system track the selected state values.
|
|
32
|
+
*
|
|
33
|
+
* Available debouncer state properties:
|
|
34
|
+
* - `canLeadingExecute`: Whether the debouncer can execute on the leading edge
|
|
35
|
+
* - `executionCount`: Number of function executions that have been completed
|
|
36
|
+
* - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution
|
|
37
|
+
* - `lastArgs`: The arguments from the most recent call to maybeExecute
|
|
38
|
+
* - `status`: Current execution status ('disabled' | 'idle' | 'pending')
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* // Default behavior - no reactive state subscriptions
|
|
43
|
+
* const [searchQuery, setSearchQuery] = createSignal('');
|
|
44
|
+
* const [debouncedQuery, debouncer] = createDebouncedValue(searchQuery, {
|
|
45
|
+
* wait: 500 // Wait 500ms after last change
|
|
46
|
+
* });
|
|
47
|
+
*
|
|
48
|
+
* // Opt-in to reactive updates when pending state changes (optimized for loading indicators)
|
|
49
|
+
* const [debouncedQuery, debouncer] = createDebouncedValue(
|
|
50
|
+
* searchQuery,
|
|
51
|
+
* { wait: 500 },
|
|
52
|
+
* (state) => ({ isPending: state.isPending })
|
|
53
|
+
* );
|
|
54
|
+
*
|
|
55
|
+
* // debouncedQuery will update 500ms after searchQuery stops changing
|
|
56
|
+
* createEffect(() => {
|
|
57
|
+
* fetchSearchResults(debouncedQuery());
|
|
58
|
+
* });
|
|
59
|
+
*
|
|
60
|
+
* // Access debouncer state via signals
|
|
61
|
+
* console.log('Is pending:', debouncer.state().isPending);
|
|
62
|
+
*
|
|
63
|
+
* // Control the debouncer
|
|
64
|
+
* debouncer.cancel(); // Cancel any pending updates
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
function createDebouncedValue(value, initialOptions, selector) {
|
|
68
|
+
const [debouncedValue, setDebouncedValue, debouncer] = require_createDebouncedSignal.createDebouncedSignal(value(), initialOptions, selector);
|
|
69
|
+
(0, solid_js.createEffect)(() => {
|
|
70
|
+
setDebouncedValue(value());
|
|
71
|
+
});
|
|
72
|
+
return [debouncedValue, debouncer];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
exports.createDebouncedValue = createDebouncedValue;
|
|
77
|
+
//# sourceMappingURL=createDebouncedValue.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDebouncedValue.cjs","names":["createDebouncedSignal"],"sources":["../../src/debouncer/createDebouncedValue.ts"],"sourcesContent":["import { createEffect } from 'solid-js'\nimport { createDebouncedSignal } from './createDebouncedSignal'\nimport type { SolidDebouncer } from './createDebouncer'\nimport type { Accessor, Setter } from 'solid-js'\nimport type {\n DebouncerOptions,\n DebouncerState,\n} from '@tanstack/pacer/debouncer'\n\n/**\n * A Solid hook that creates a debounced value that updates only after a specified delay.\n * Unlike createDebouncedSignal, this hook automatically tracks changes to the input value\n * and updates the debounced value accordingly.\n *\n * The debounced value will only update after the specified wait time has elapsed since\n * the last change to the input value. If the input value changes again before the wait\n * time expires, the timer resets and starts waiting again.\n *\n * This is useful for deriving debounced values from props or state that change frequently,\n * like search queries or form inputs, where you want to limit how often downstream effects\n * or calculations occur.\n *\n * The hook returns a tuple containing:\n * - An Accessor that provides the current debounced value\n * - The debouncer instance with control methods\n *\n * ## State Management and Selector\n *\n * The hook uses TanStack Store for reactive state management via the underlying debouncer instance.\n * The `selector` parameter allows you to specify which debouncer state changes will trigger reactive updates,\n * optimizing performance by preventing unnecessary subscriptions 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 reactive updates and gives you\n * full control over when your component subscribes to state changes. Only when you provide a selector will\n * the reactive system track the selected state values.\n *\n * Available debouncer state properties:\n * - `canLeadingExecute`: Whether the debouncer can execute on the leading edge\n * - `executionCount`: Number of function executions that have been completed\n * - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution\n * - `lastArgs`: The arguments from the most recent call to maybeExecute\n * - `status`: Current execution status ('disabled' | 'idle' | 'pending')\n *\n * @example\n * ```tsx\n * // Default behavior - no reactive state subscriptions\n * const [searchQuery, setSearchQuery] = createSignal('');\n * const [debouncedQuery, debouncer] = createDebouncedValue(searchQuery, {\n * wait: 500 // Wait 500ms after last change\n * });\n *\n * // Opt-in to reactive updates when pending state changes (optimized for loading indicators)\n * const [debouncedQuery, debouncer] = createDebouncedValue(\n * searchQuery,\n * { wait: 500 },\n * (state) => ({ isPending: state.isPending })\n * );\n *\n * // debouncedQuery will update 500ms after searchQuery stops changing\n * createEffect(() => {\n * fetchSearchResults(debouncedQuery());\n * });\n *\n * // Access debouncer state via signals\n * console.log('Is pending:', debouncer.state().isPending);\n *\n * // Control the debouncer\n * debouncer.cancel(); // Cancel any pending updates\n * ```\n */\nexport function createDebouncedValue<TValue, TSelected = {}>(\n value: Accessor<TValue>,\n initialOptions: DebouncerOptions<Setter<TValue>>,\n selector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): [Accessor<TValue>, SolidDebouncer<Setter<TValue>, TSelected>] {\n const [debouncedValue, setDebouncedValue, debouncer] = createDebouncedSignal(\n value(),\n initialOptions,\n selector,\n )\n\n createEffect(() => {\n setDebouncedValue(value() as any)\n })\n\n return [debouncedValue, debouncer]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuEA,SAAgB,qBACd,OACA,gBACA,UAC+D;CAC/D,MAAM,CAAC,gBAAgB,mBAAmB,aAAaA,oDACrD,OAAO,EACP,gBACA,SACD;AAED,kCAAmB;AACjB,oBAAkB,OAAO,CAAQ;GACjC;AAEF,QAAO,CAAC,gBAAgB,UAAU"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { SolidDebouncer } from
|
|
2
|
-
import { Accessor, Setter } from
|
|
3
|
-
import { DebouncerOptions, DebouncerState } from
|
|
1
|
+
import { SolidDebouncer } from "./createDebouncer.cjs";
|
|
2
|
+
import { Accessor, Setter } from "solid-js";
|
|
3
|
+
import { DebouncerOptions, DebouncerState } from "@tanstack/pacer/debouncer";
|
|
4
|
+
|
|
5
|
+
//#region src/debouncer/createDebouncedValue.d.ts
|
|
6
|
+
|
|
4
7
|
/**
|
|
5
8
|
* A Solid hook that creates a debounced value that updates only after a specified delay.
|
|
6
9
|
* Unlike createDebouncedSignal, this hook automatically tracks changes to the input value
|
|
@@ -63,4 +66,7 @@ import { DebouncerOptions, DebouncerState } from '@tanstack/pacer/debouncer';
|
|
|
63
66
|
* debouncer.cancel(); // Cancel any pending updates
|
|
64
67
|
* ```
|
|
65
68
|
*/
|
|
66
|
-
|
|
69
|
+
declare function createDebouncedValue<TValue, TSelected = {}>(value: Accessor<TValue>, initialOptions: DebouncerOptions<Setter<TValue>>, selector?: (state: DebouncerState<Setter<TValue>>) => TSelected): [Accessor<TValue>, SolidDebouncer<Setter<TValue>, TSelected>];
|
|
70
|
+
//#endregion
|
|
71
|
+
export { createDebouncedValue };
|
|
72
|
+
//# sourceMappingURL=createDebouncedValue.d.cts.map
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { SolidDebouncer } from
|
|
2
|
-
import { Accessor, Setter } from
|
|
3
|
-
import { DebouncerOptions, DebouncerState } from
|
|
1
|
+
import { SolidDebouncer } from "./createDebouncer.js";
|
|
2
|
+
import { Accessor, Setter } from "solid-js";
|
|
3
|
+
import { DebouncerOptions, DebouncerState } from "@tanstack/pacer/debouncer";
|
|
4
|
+
|
|
5
|
+
//#region src/debouncer/createDebouncedValue.d.ts
|
|
6
|
+
|
|
4
7
|
/**
|
|
5
8
|
* A Solid hook that creates a debounced value that updates only after a specified delay.
|
|
6
9
|
* Unlike createDebouncedSignal, this hook automatically tracks changes to the input value
|
|
@@ -63,4 +66,7 @@ import { DebouncerOptions, DebouncerState } from '@tanstack/pacer/debouncer';
|
|
|
63
66
|
* debouncer.cancel(); // Cancel any pending updates
|
|
64
67
|
* ```
|
|
65
68
|
*/
|
|
66
|
-
|
|
69
|
+
declare function createDebouncedValue<TValue, TSelected = {}>(value: Accessor<TValue>, initialOptions: DebouncerOptions<Setter<TValue>>, selector?: (state: DebouncerState<Setter<TValue>>) => TSelected): [Accessor<TValue>, SolidDebouncer<Setter<TValue>, TSelected>];
|
|
70
|
+
//#endregion
|
|
71
|
+
export { createDebouncedValue };
|
|
72
|
+
//# sourceMappingURL=createDebouncedValue.d.ts.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { createDebouncedSignal } from "./createDebouncedSignal.js";
|
|
2
|
+
import { createEffect } from "solid-js";
|
|
3
|
+
|
|
4
|
+
//#region src/debouncer/createDebouncedValue.ts
|
|
5
|
+
/**
|
|
6
|
+
* A Solid hook that creates a debounced value that updates only after a specified delay.
|
|
7
|
+
* Unlike createDebouncedSignal, this hook automatically tracks changes to the input value
|
|
8
|
+
* and updates the debounced value accordingly.
|
|
9
|
+
*
|
|
10
|
+
* The debounced value will only update after the specified wait time has elapsed since
|
|
11
|
+
* the last change to the input value. If the input value changes again before the wait
|
|
12
|
+
* time expires, the timer resets and starts waiting again.
|
|
13
|
+
*
|
|
14
|
+
* This is useful for deriving debounced values from props or state that change frequently,
|
|
15
|
+
* like search queries or form inputs, where you want to limit how often downstream effects
|
|
16
|
+
* or calculations occur.
|
|
17
|
+
*
|
|
18
|
+
* The hook returns a tuple containing:
|
|
19
|
+
* - An Accessor that provides the current debounced value
|
|
20
|
+
* - The debouncer instance with control methods
|
|
21
|
+
*
|
|
22
|
+
* ## State Management and Selector
|
|
23
|
+
*
|
|
24
|
+
* The hook uses TanStack Store for reactive state management via the underlying debouncer instance.
|
|
25
|
+
* The `selector` parameter allows you to specify which debouncer state changes will trigger reactive updates,
|
|
26
|
+
* optimizing performance by preventing unnecessary subscriptions when irrelevant state changes occur.
|
|
27
|
+
*
|
|
28
|
+
* **By default, there will be no reactive state subscriptions** and you must opt-in to state
|
|
29
|
+
* tracking by providing a selector function. This prevents unnecessary reactive updates and gives you
|
|
30
|
+
* full control over when your component subscribes to state changes. Only when you provide a selector will
|
|
31
|
+
* the reactive system track the selected state values.
|
|
32
|
+
*
|
|
33
|
+
* Available debouncer state properties:
|
|
34
|
+
* - `canLeadingExecute`: Whether the debouncer can execute on the leading edge
|
|
35
|
+
* - `executionCount`: Number of function executions that have been completed
|
|
36
|
+
* - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution
|
|
37
|
+
* - `lastArgs`: The arguments from the most recent call to maybeExecute
|
|
38
|
+
* - `status`: Current execution status ('disabled' | 'idle' | 'pending')
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* // Default behavior - no reactive state subscriptions
|
|
43
|
+
* const [searchQuery, setSearchQuery] = createSignal('');
|
|
44
|
+
* const [debouncedQuery, debouncer] = createDebouncedValue(searchQuery, {
|
|
45
|
+
* wait: 500 // Wait 500ms after last change
|
|
46
|
+
* });
|
|
47
|
+
*
|
|
48
|
+
* // Opt-in to reactive updates when pending state changes (optimized for loading indicators)
|
|
49
|
+
* const [debouncedQuery, debouncer] = createDebouncedValue(
|
|
50
|
+
* searchQuery,
|
|
51
|
+
* { wait: 500 },
|
|
52
|
+
* (state) => ({ isPending: state.isPending })
|
|
53
|
+
* );
|
|
54
|
+
*
|
|
55
|
+
* // debouncedQuery will update 500ms after searchQuery stops changing
|
|
56
|
+
* createEffect(() => {
|
|
57
|
+
* fetchSearchResults(debouncedQuery());
|
|
58
|
+
* });
|
|
59
|
+
*
|
|
60
|
+
* // Access debouncer state via signals
|
|
61
|
+
* console.log('Is pending:', debouncer.state().isPending);
|
|
62
|
+
*
|
|
63
|
+
* // Control the debouncer
|
|
64
|
+
* debouncer.cancel(); // Cancel any pending updates
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
function createDebouncedValue(value, initialOptions, selector) {
|
|
68
|
+
const [debouncedValue, setDebouncedValue, debouncer] = createDebouncedSignal(value(), initialOptions, selector);
|
|
69
|
+
createEffect(() => {
|
|
70
|
+
setDebouncedValue(value());
|
|
71
|
+
});
|
|
72
|
+
return [debouncedValue, debouncer];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
export { createDebouncedValue };
|
|
77
|
+
//# sourceMappingURL=createDebouncedValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDebouncedValue.js","names":[],"sources":["../../src/debouncer/createDebouncedValue.ts"],"sourcesContent":["import { createEffect } from 'solid-js'\nimport { createDebouncedSignal } from './createDebouncedSignal'\nimport type { SolidDebouncer } from './createDebouncer'\nimport type { Accessor, Setter } from 'solid-js'\nimport type {\n DebouncerOptions,\n DebouncerState,\n} from '@tanstack/pacer/debouncer'\n\n/**\n * A Solid hook that creates a debounced value that updates only after a specified delay.\n * Unlike createDebouncedSignal, this hook automatically tracks changes to the input value\n * and updates the debounced value accordingly.\n *\n * The debounced value will only update after the specified wait time has elapsed since\n * the last change to the input value. If the input value changes again before the wait\n * time expires, the timer resets and starts waiting again.\n *\n * This is useful for deriving debounced values from props or state that change frequently,\n * like search queries or form inputs, where you want to limit how often downstream effects\n * or calculations occur.\n *\n * The hook returns a tuple containing:\n * - An Accessor that provides the current debounced value\n * - The debouncer instance with control methods\n *\n * ## State Management and Selector\n *\n * The hook uses TanStack Store for reactive state management via the underlying debouncer instance.\n * The `selector` parameter allows you to specify which debouncer state changes will trigger reactive updates,\n * optimizing performance by preventing unnecessary subscriptions 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 reactive updates and gives you\n * full control over when your component subscribes to state changes. Only when you provide a selector will\n * the reactive system track the selected state values.\n *\n * Available debouncer state properties:\n * - `canLeadingExecute`: Whether the debouncer can execute on the leading edge\n * - `executionCount`: Number of function executions that have been completed\n * - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution\n * - `lastArgs`: The arguments from the most recent call to maybeExecute\n * - `status`: Current execution status ('disabled' | 'idle' | 'pending')\n *\n * @example\n * ```tsx\n * // Default behavior - no reactive state subscriptions\n * const [searchQuery, setSearchQuery] = createSignal('');\n * const [debouncedQuery, debouncer] = createDebouncedValue(searchQuery, {\n * wait: 500 // Wait 500ms after last change\n * });\n *\n * // Opt-in to reactive updates when pending state changes (optimized for loading indicators)\n * const [debouncedQuery, debouncer] = createDebouncedValue(\n * searchQuery,\n * { wait: 500 },\n * (state) => ({ isPending: state.isPending })\n * );\n *\n * // debouncedQuery will update 500ms after searchQuery stops changing\n * createEffect(() => {\n * fetchSearchResults(debouncedQuery());\n * });\n *\n * // Access debouncer state via signals\n * console.log('Is pending:', debouncer.state().isPending);\n *\n * // Control the debouncer\n * debouncer.cancel(); // Cancel any pending updates\n * ```\n */\nexport function createDebouncedValue<TValue, TSelected = {}>(\n value: Accessor<TValue>,\n initialOptions: DebouncerOptions<Setter<TValue>>,\n selector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): [Accessor<TValue>, SolidDebouncer<Setter<TValue>, TSelected>] {\n const [debouncedValue, setDebouncedValue, debouncer] = createDebouncedSignal(\n value(),\n initialOptions,\n selector,\n )\n\n createEffect(() => {\n setDebouncedValue(value() as any)\n })\n\n return [debouncedValue, debouncer]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuEA,SAAgB,qBACd,OACA,gBACA,UAC+D;CAC/D,MAAM,CAAC,gBAAgB,mBAAmB,aAAa,sBACrD,OAAO,EACP,gBACA,SACD;AAED,oBAAmB;AACjB,oBAAkB,OAAO,CAAQ;GACjC;AAEF,QAAO,CAAC,gBAAgB,UAAU"}
|
|
@@ -0,0 +1,101 @@
|
|
|
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_debouncer = require("@tanstack/pacer/debouncer");
|
|
5
|
+
|
|
6
|
+
//#region src/debouncer/createDebouncer.ts
|
|
7
|
+
/**
|
|
8
|
+
* A Solid hook that creates and manages a Debouncer instance.
|
|
9
|
+
*
|
|
10
|
+
* This is a lower-level hook that provides direct access to the Debouncer's functionality without
|
|
11
|
+
* any built-in state management. This allows you to integrate it with any state management solution
|
|
12
|
+
* you prefer (createSignal, Redux, Zustand, etc.).
|
|
13
|
+
*
|
|
14
|
+
* This hook provides debouncing functionality to limit how often a function can be called,
|
|
15
|
+
* waiting for a specified delay before executing the latest call. This is useful for handling
|
|
16
|
+
* frequent events like window resizing, scroll events, or real-time search inputs.
|
|
17
|
+
*
|
|
18
|
+
* The debouncer will only execute the function after the specified wait time has elapsed
|
|
19
|
+
* since the last call. If the function is called again before the wait time expires, the
|
|
20
|
+
* timer resets and starts waiting again.
|
|
21
|
+
*
|
|
22
|
+
* ## State Management and Selector
|
|
23
|
+
*
|
|
24
|
+
* The hook uses TanStack Store for reactive state management. The `selector` parameter allows you
|
|
25
|
+
* to specify which state changes will trigger a re-render, optimizing performance by preventing
|
|
26
|
+
* unnecessary re-renders when irrelevant state changes occur.
|
|
27
|
+
*
|
|
28
|
+
* **By default, there will be no reactive state subscriptions** and you must opt-in to state
|
|
29
|
+
* tracking by providing a selector function. This prevents unnecessary re-renders and gives you
|
|
30
|
+
* full control over when your component updates. Only when you provide a selector will the
|
|
31
|
+
* component re-render when the selected state values change.
|
|
32
|
+
*
|
|
33
|
+
* Available state properties:
|
|
34
|
+
* - `canLeadingExecute`: Whether the debouncer can execute on the leading edge
|
|
35
|
+
* - `executionCount`: Number of function executions that have been completed
|
|
36
|
+
* - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution
|
|
37
|
+
* - `lastArgs`: The arguments from the most recent call to maybeExecute
|
|
38
|
+
* - `status`: Current execution status ('disabled' | 'idle' | 'pending')
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* // Default behavior - no reactive state subscriptions
|
|
43
|
+
* const debouncer = createDebouncer(
|
|
44
|
+
* (query: string) => fetchSearchResults(query),
|
|
45
|
+
* { wait: 500 }
|
|
46
|
+
* );
|
|
47
|
+
*
|
|
48
|
+
* // Opt-in to re-render when isPending changes (optimized for loading states)
|
|
49
|
+
* const debouncer = createDebouncer(
|
|
50
|
+
* (query: string) => fetchSearchResults(query),
|
|
51
|
+
* { wait: 500 },
|
|
52
|
+
* (state) => ({ isPending: state.isPending })
|
|
53
|
+
* );
|
|
54
|
+
*
|
|
55
|
+
* // Opt-in to re-render when executionCount changes (optimized for tracking execution)
|
|
56
|
+
* const debouncer = createDebouncer(
|
|
57
|
+
* (query: string) => fetchSearchResults(query),
|
|
58
|
+
* { wait: 500 },
|
|
59
|
+
* (state) => ({ executionCount: state.executionCount })
|
|
60
|
+
* );
|
|
61
|
+
*
|
|
62
|
+
* // Multiple state properties - re-render when any of these change
|
|
63
|
+
* const debouncer = createDebouncer(
|
|
64
|
+
* (query: string) => fetchSearchResults(query),
|
|
65
|
+
* { wait: 500 },
|
|
66
|
+
* (state) => ({
|
|
67
|
+
* isPending: state.isPending,
|
|
68
|
+
* executionCount: state.executionCount,
|
|
69
|
+
* status: state.status
|
|
70
|
+
* })
|
|
71
|
+
* );
|
|
72
|
+
*
|
|
73
|
+
* // In an event handler
|
|
74
|
+
* const handleChange = (e) => {
|
|
75
|
+
* debouncer.maybeExecute(e.target.value);
|
|
76
|
+
* };
|
|
77
|
+
*
|
|
78
|
+
* // Access the selected state (will be empty object {} unless selector provided)
|
|
79
|
+
* const { isPending } = debouncer.state();
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
function createDebouncer(fn, options, selector = () => ({})) {
|
|
83
|
+
const asyncDebouncer = new __tanstack_pacer_debouncer.Debouncer(fn, {
|
|
84
|
+
...require_PacerProvider.useDefaultPacerOptions().debouncer,
|
|
85
|
+
...options
|
|
86
|
+
});
|
|
87
|
+
const state = (0, __tanstack_solid_store.useStore)(asyncDebouncer.store, selector);
|
|
88
|
+
(0, solid_js.createEffect)(() => {
|
|
89
|
+
(0, solid_js.onCleanup)(() => {
|
|
90
|
+
asyncDebouncer.cancel();
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
return {
|
|
94
|
+
...asyncDebouncer,
|
|
95
|
+
state
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
//#endregion
|
|
100
|
+
exports.createDebouncer = createDebouncer;
|
|
101
|
+
//# sourceMappingURL=createDebouncer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDebouncer.cjs","names":["Debouncer","useDefaultPacerOptions"],"sources":["../../src/debouncer/createDebouncer.ts"],"sourcesContent":["import { Debouncer } from '@tanstack/pacer/debouncer'\nimport { createEffect, onCleanup } from 'solid-js'\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 { AnyFunction } from '@tanstack/pacer/types'\nimport type {\n DebouncerOptions,\n DebouncerState,\n} from '@tanstack/pacer/debouncer'\n\nexport interface SolidDebouncer<\n TFn extends AnyFunction,\n TSelected = {},\n> extends Omit<Debouncer<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<DebouncerState<TFn>>>\n}\n\n/**\n * A Solid hook that creates and manages a Debouncer instance.\n *\n * This is a lower-level hook that provides direct access to the Debouncer's functionality without\n * any built-in state management. This allows you to integrate it with any state management solution\n * you prefer (createSignal, Redux, Zustand, etc.).\n *\n * This hook provides debouncing functionality to limit how often a function can be called,\n * waiting for a specified delay before executing the latest call. This is useful for handling\n * frequent events like window resizing, scroll events, or real-time search inputs.\n *\n * The debouncer will only execute the function after the specified wait time has elapsed\n * since the last call. If the function is called again before the wait time expires, the\n * timer resets and starts waiting again.\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 * - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution\n * - `lastArgs`: The arguments from the most recent call to maybeExecute\n * - `status`: Current execution status ('disabled' | 'idle' | 'pending')\n *\n * @example\n * ```tsx\n * // Default behavior - no reactive state subscriptions\n * const debouncer = createDebouncer(\n * (query: string) => fetchSearchResults(query),\n * { wait: 500 }\n * );\n *\n * // Opt-in to re-render when isPending changes (optimized for loading states)\n * const debouncer = createDebouncer(\n * (query: string) => fetchSearchResults(query),\n * { wait: 500 },\n * (state) => ({ isPending: state.isPending })\n * );\n *\n * // Opt-in to re-render when executionCount changes (optimized for tracking execution)\n * const debouncer = createDebouncer(\n * (query: string) => fetchSearchResults(query),\n * { wait: 500 },\n * (state) => ({ executionCount: state.executionCount })\n * );\n *\n * // Multiple state properties - re-render when any of these change\n * const debouncer = createDebouncer(\n * (query: string) => fetchSearchResults(query),\n * { wait: 500 },\n * (state) => ({\n * isPending: state.isPending,\n * executionCount: state.executionCount,\n * status: state.status\n * })\n * );\n *\n * // In an event handler\n * const handleChange = (e) => {\n * debouncer.maybeExecute(e.target.value);\n * };\n *\n * // Access the selected state (will be empty object {} unless selector provided)\n * const { isPending } = debouncer.state();\n * ```\n */\nexport function createDebouncer<TFn extends AnyFunction, TSelected = {}>(\n fn: TFn,\n options: DebouncerOptions<TFn>,\n selector: (state: DebouncerState<TFn>) => TSelected = () => ({}) as TSelected,\n): SolidDebouncer<TFn, TSelected> {\n const mergedOptions = {\n ...useDefaultPacerOptions().debouncer,\n ...options,\n } as DebouncerOptions<TFn>\n\n const asyncDebouncer = new Debouncer<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 SolidDebouncer<TFn, TSelected> // omit `store` in favor of `state`\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyGA,SAAgB,gBACd,IACA,SACA,kBAA6D,EAAE,GAC/B;CAMhC,MAAM,iBAAiB,IAAIA,qCAAe,IALpB;EACpB,GAAGC,8CAAwB,CAAC;EAC5B,GAAG;EACJ,CAE2D;CAE5D,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 {
|
|
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 { AnyFunction } from "@tanstack/pacer/types";
|
|
4
|
+
import { Debouncer, DebouncerOptions, DebouncerState } from "@tanstack/pacer/debouncer";
|
|
5
|
+
|
|
6
|
+
//#region src/debouncer/createDebouncer.d.ts
|
|
7
|
+
interface SolidDebouncer<TFn extends AnyFunction, TSelected = {}> extends Omit<Debouncer<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<DebouncerState<TFn>>>;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
22
|
* A Solid hook that creates and manages a Debouncer instance.
|
|
@@ -91,4 +93,7 @@ export interface SolidDebouncer<TFn extends AnyFunction, TSelected = {}> extends
|
|
|
91
93
|
* const { isPending } = debouncer.state();
|
|
92
94
|
* ```
|
|
93
95
|
*/
|
|
94
|
-
|
|
96
|
+
declare function createDebouncer<TFn extends AnyFunction, TSelected = {}>(fn: TFn, options: DebouncerOptions<TFn>, selector?: (state: DebouncerState<TFn>) => TSelected): SolidDebouncer<TFn, TSelected>;
|
|
97
|
+
//#endregion
|
|
98
|
+
export { SolidDebouncer, createDebouncer };
|
|
99
|
+
//# sourceMappingURL=createDebouncer.d.cts.map
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Store } from
|
|
3
|
-
import {
|
|
4
|
-
import { AnyFunction } from
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { Accessor } from "solid-js";
|
|
2
|
+
import { Store } from "@tanstack/solid-store";
|
|
3
|
+
import { Debouncer, DebouncerOptions, DebouncerState } from "@tanstack/pacer/debouncer";
|
|
4
|
+
import { AnyFunction } from "@tanstack/pacer/types";
|
|
5
|
+
|
|
6
|
+
//#region src/debouncer/createDebouncer.d.ts
|
|
7
|
+
interface SolidDebouncer<TFn extends AnyFunction, TSelected = {}> extends Omit<Debouncer<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<DebouncerState<TFn>>>;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
22
|
* A Solid hook that creates and manages a Debouncer instance.
|
|
@@ -91,4 +93,7 @@ export interface SolidDebouncer<TFn extends AnyFunction, TSelected = {}> extends
|
|
|
91
93
|
* const { isPending } = debouncer.state();
|
|
92
94
|
* ```
|
|
93
95
|
*/
|
|
94
|
-
|
|
96
|
+
declare function createDebouncer<TFn extends AnyFunction, TSelected = {}>(fn: TFn, options: DebouncerOptions<TFn>, selector?: (state: DebouncerState<TFn>) => TSelected): SolidDebouncer<TFn, TSelected>;
|
|
97
|
+
//#endregion
|
|
98
|
+
export { SolidDebouncer, createDebouncer };
|
|
99
|
+
//# sourceMappingURL=createDebouncer.d.ts.map
|