@tanstack/solid-pacer 0.21.1 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/README.md +21 -6
  2. package/dist/async-batcher/createAsyncBatcher.d.ts +5 -10
  3. package/dist/async-batcher/createAsyncBatcher.js +2 -5
  4. package/dist/async-debouncer/createAsyncDebouncer.d.ts +8 -12
  5. package/dist/async-debouncer/createAsyncDebouncer.js +5 -7
  6. package/dist/async-queuer/createAsyncQueuer.d.ts +9 -12
  7. package/dist/async-queuer/createAsyncQueuer.js +4 -5
  8. package/dist/async-rate-limiter/createAsyncRateLimiter.d.ts +10 -13
  9. package/dist/async-rate-limiter/createAsyncRateLimiter.js +7 -8
  10. package/dist/async-throttler/createAsyncThrottler.d.ts +8 -14
  11. package/dist/async-throttler/createAsyncThrottler.js +5 -9
  12. package/dist/batcher/createBatcher.d.ts +11 -15
  13. package/dist/batcher/createBatcher.js +6 -8
  14. package/dist/debouncer/createDebouncedSignal.d.ts +2 -5
  15. package/dist/debouncer/createDebouncedSignal.js +1 -2
  16. package/dist/debouncer/createDebouncedValue.d.ts +2 -5
  17. package/dist/debouncer/createDebouncedValue.js +1 -2
  18. package/dist/debouncer/createDebouncer.d.ts +4 -7
  19. package/dist/debouncer/createDebouncer.js +1 -2
  20. package/dist/provider/PacerProvider.d.ts +6 -9
  21. package/dist/provider/PacerProvider.js +1 -2
  22. package/dist/queuer/createQueuedSignal.d.ts +2 -5
  23. package/dist/queuer/createQueuedSignal.js +1 -2
  24. package/dist/queuer/createQueuer.d.ts +4 -7
  25. package/dist/queuer/createQueuer.js +1 -2
  26. package/dist/rate-limiter/createRateLimitedSignal.d.ts +12 -14
  27. package/dist/rate-limiter/createRateLimitedSignal.js +11 -11
  28. package/dist/rate-limiter/createRateLimitedValue.d.ts +2 -5
  29. package/dist/rate-limiter/createRateLimitedValue.js +1 -2
  30. package/dist/rate-limiter/createRateLimiter.d.ts +8 -10
  31. package/dist/rate-limiter/createRateLimiter.js +5 -5
  32. package/dist/throttler/createThrottledSignal.d.ts +2 -7
  33. package/dist/throttler/createThrottledSignal.js +1 -4
  34. package/dist/throttler/createThrottledValue.d.ts +2 -7
  35. package/dist/throttler/createThrottledValue.js +1 -4
  36. package/dist/throttler/createThrottler.d.ts +4 -9
  37. package/dist/throttler/createThrottler.js +1 -4
  38. package/package.json +24 -68
  39. package/dist/async-batcher/createAsyncBatcher.cjs +0 -166
  40. package/dist/async-batcher/createAsyncBatcher.cjs.map +0 -1
  41. package/dist/async-batcher/createAsyncBatcher.d.cts +0 -178
  42. package/dist/async-batcher/createAsyncBatcher.js.map +0 -1
  43. package/dist/async-batcher/index.cjs +0 -11
  44. package/dist/async-batcher/index.d.cts +0 -3
  45. package/dist/async-debouncer/createAsyncDebouncer.cjs +0 -151
  46. package/dist/async-debouncer/createAsyncDebouncer.cjs.map +0 -1
  47. package/dist/async-debouncer/createAsyncDebouncer.d.cts +0 -164
  48. package/dist/async-debouncer/createAsyncDebouncer.js.map +0 -1
  49. package/dist/async-debouncer/index.cjs +0 -11
  50. package/dist/async-debouncer/index.d.cts +0 -3
  51. package/dist/async-queuer/createAsyncQueuer.cjs +0 -158
  52. package/dist/async-queuer/createAsyncQueuer.cjs.map +0 -1
  53. package/dist/async-queuer/createAsyncQueuer.d.cts +0 -170
  54. package/dist/async-queuer/createAsyncQueuer.js.map +0 -1
  55. package/dist/async-queuer/index.cjs +0 -11
  56. package/dist/async-queuer/index.d.cts +0 -3
  57. package/dist/async-rate-limiter/createAsyncRateLimiter.cjs +0 -193
  58. package/dist/async-rate-limiter/createAsyncRateLimiter.cjs.map +0 -1
  59. package/dist/async-rate-limiter/createAsyncRateLimiter.d.cts +0 -209
  60. package/dist/async-rate-limiter/createAsyncRateLimiter.js.map +0 -1
  61. package/dist/async-rate-limiter/index.cjs +0 -11
  62. package/dist/async-rate-limiter/index.d.cts +0 -3
  63. package/dist/async-throttler/createAsyncThrottler.cjs +0 -151
  64. package/dist/async-throttler/createAsyncThrottler.cjs.map +0 -1
  65. package/dist/async-throttler/createAsyncThrottler.d.cts +0 -164
  66. package/dist/async-throttler/createAsyncThrottler.js.map +0 -1
  67. package/dist/async-throttler/index.cjs +0 -11
  68. package/dist/async-throttler/index.d.cts +0 -3
  69. package/dist/batcher/createBatcher.cjs +0 -132
  70. package/dist/batcher/createBatcher.cjs.map +0 -1
  71. package/dist/batcher/createBatcher.d.cts +0 -147
  72. package/dist/batcher/createBatcher.js.map +0 -1
  73. package/dist/batcher/index.cjs +0 -11
  74. package/dist/batcher/index.d.cts +0 -3
  75. package/dist/debouncer/createDebouncedSignal.cjs +0 -88
  76. package/dist/debouncer/createDebouncedSignal.cjs.map +0 -1
  77. package/dist/debouncer/createDebouncedSignal.d.cts +0 -80
  78. package/dist/debouncer/createDebouncedSignal.js.map +0 -1
  79. package/dist/debouncer/createDebouncedValue.cjs +0 -77
  80. package/dist/debouncer/createDebouncedValue.cjs.map +0 -1
  81. package/dist/debouncer/createDebouncedValue.d.cts +0 -71
  82. package/dist/debouncer/createDebouncedValue.js.map +0 -1
  83. package/dist/debouncer/createDebouncer.cjs +0 -129
  84. package/dist/debouncer/createDebouncer.cjs.map +0 -1
  85. package/dist/debouncer/createDebouncer.d.cts +0 -145
  86. package/dist/debouncer/createDebouncer.js.map +0 -1
  87. package/dist/debouncer/index.cjs +0 -15
  88. package/dist/debouncer/index.d.cts +0 -5
  89. package/dist/index.cjs +0 -47
  90. package/dist/index.d.cts +0 -20
  91. package/dist/provider/PacerProvider.cjs +0 -27
  92. package/dist/provider/PacerProvider.cjs.map +0 -1
  93. package/dist/provider/PacerProvider.d.cts +0 -29
  94. package/dist/provider/PacerProvider.js.map +0 -1
  95. package/dist/provider/index.cjs +0 -6
  96. package/dist/provider/index.d.cts +0 -2
  97. package/dist/queuer/createQueuedSignal.cjs +0 -129
  98. package/dist/queuer/createQueuedSignal.cjs.map +0 -1
  99. package/dist/queuer/createQueuedSignal.d.cts +0 -122
  100. package/dist/queuer/createQueuedSignal.js.map +0 -1
  101. package/dist/queuer/createQueuer.cjs +0 -133
  102. package/dist/queuer/createQueuer.cjs.map +0 -1
  103. package/dist/queuer/createQueuer.d.cts +0 -148
  104. package/dist/queuer/createQueuer.js.map +0 -1
  105. package/dist/queuer/index.cjs +0 -13
  106. package/dist/queuer/index.d.cts +0 -4
  107. package/dist/rate-limiter/createRateLimitedSignal.cjs +0 -102
  108. package/dist/rate-limiter/createRateLimitedSignal.cjs.map +0 -1
  109. package/dist/rate-limiter/createRateLimitedSignal.d.cts +0 -94
  110. package/dist/rate-limiter/createRateLimitedSignal.js.map +0 -1
  111. package/dist/rate-limiter/createRateLimitedValue.cjs +0 -102
  112. package/dist/rate-limiter/createRateLimitedValue.cjs.map +0 -1
  113. package/dist/rate-limiter/createRateLimitedValue.d.cts +0 -96
  114. package/dist/rate-limiter/createRateLimitedValue.js.map +0 -1
  115. package/dist/rate-limiter/createRateLimiter.cjs +0 -157
  116. package/dist/rate-limiter/createRateLimiter.cjs.map +0 -1
  117. package/dist/rate-limiter/createRateLimiter.d.cts +0 -174
  118. package/dist/rate-limiter/createRateLimiter.js.map +0 -1
  119. package/dist/rate-limiter/index.cjs +0 -15
  120. package/dist/rate-limiter/index.d.cts +0 -5
  121. package/dist/throttler/createThrottledSignal.cjs +0 -79
  122. package/dist/throttler/createThrottledSignal.cjs.map +0 -1
  123. package/dist/throttler/createThrottledSignal.d.cts +0 -71
  124. package/dist/throttler/createThrottledSignal.js.map +0 -1
  125. package/dist/throttler/createThrottledValue.cjs +0 -74
  126. package/dist/throttler/createThrottledValue.cjs.map +0 -1
  127. package/dist/throttler/createThrottledValue.d.cts +0 -68
  128. package/dist/throttler/createThrottledValue.js.map +0 -1
  129. package/dist/throttler/createThrottler.cjs +0 -132
  130. package/dist/throttler/createThrottler.cjs.map +0 -1
  131. package/dist/throttler/createThrottler.d.cts +0 -148
  132. package/dist/throttler/createThrottler.js.map +0 -1
  133. package/dist/throttler/index.cjs +0 -15
  134. package/dist/throttler/index.d.cts +0 -5
  135. package/dist/types/index.cjs +0 -9
  136. package/dist/types/index.d.cts +0 -1
  137. package/dist/utils/index.cjs +0 -9
  138. package/dist/utils/index.d.cts +0 -1
  139. package/src/async-batcher/createAsyncBatcher.ts +0 -234
  140. package/src/async-batcher/index.ts +0 -3
  141. package/src/async-debouncer/createAsyncDebouncer.ts +0 -225
  142. package/src/async-debouncer/index.ts +0 -4
  143. package/src/async-queuer/createAsyncQueuer.ts +0 -226
  144. package/src/async-queuer/index.ts +0 -3
  145. package/src/async-rate-limiter/createAsyncRateLimiter.ts +0 -269
  146. package/src/async-rate-limiter/index.ts +0 -4
  147. package/src/async-throttler/createAsyncThrottler.ts +0 -225
  148. package/src/async-throttler/index.ts +0 -4
  149. package/src/batcher/createBatcher.ts +0 -199
  150. package/src/batcher/index.ts +0 -3
  151. package/src/debouncer/createDebouncedSignal.ts +0 -92
  152. package/src/debouncer/createDebouncedValue.ts +0 -85
  153. package/src/debouncer/createDebouncer.ts +0 -201
  154. package/src/debouncer/index.ts +0 -6
  155. package/src/index.ts +0 -46
  156. package/src/provider/PacerProvider.tsx +0 -63
  157. package/src/provider/index.ts +0 -1
  158. package/src/queuer/createQueuedSignal.ts +0 -138
  159. package/src/queuer/createQueuer.ts +0 -199
  160. package/src/queuer/index.ts +0 -4
  161. package/src/rate-limiter/createRateLimitedSignal.ts +0 -117
  162. package/src/rate-limiter/createRateLimitedValue.ts +0 -110
  163. package/src/rate-limiter/createRateLimiter.ts +0 -226
  164. package/src/rate-limiter/index.ts +0 -5
  165. package/src/throttler/createThrottledSignal.ts +0 -81
  166. package/src/throttler/createThrottledValue.ts +0 -82
  167. package/src/throttler/createThrottler.ts +0 -204
  168. package/src/throttler/index.ts +0 -6
  169. package/src/types/index.ts +0 -1
  170. package/src/utils/index.ts +0 -1
@@ -1,147 +0,0 @@
1
- import { Store } from "@tanstack/solid-store";
2
- import { Accessor, JSX } from "solid-js";
3
- import { Batcher, BatcherOptions, BatcherState } from "@tanstack/pacer/batcher";
4
-
5
- //#region src/batcher/createBatcher.d.ts
6
- interface SolidBatcherOptions<TValue, TSelected = {}> extends BatcherOptions<TValue> {
7
- /**
8
- * Optional callback invoked when the owning component unmounts. Receives the batcher instance.
9
- * When provided, replaces the default cleanup (cancel); use it to call flush(), reset(), cancel(), add logging, etc.
10
- */
11
- onUnmount?: (batcher: SolidBatcher<TValue, TSelected>) => void;
12
- }
13
- interface SolidBatcher<TValue, TSelected = {}> extends Omit<Batcher<TValue>, 'store'> {
14
- /**
15
- * A Solid component that allows you to subscribe to the batcher state.
16
- *
17
- * This is useful for tracking specific parts of the batcher state
18
- * deep in your component tree without needing to pass a selector to the hook.
19
- *
20
- * @example
21
- * <batcher.Subscribe selector={(state) => ({ size: state.size, isRunning: state.isRunning })}>
22
- * {(state) => (
23
- * <div>Batch: {state().size} items, {state().isRunning ? 'Processing' : 'Idle'}</div>
24
- * )}
25
- * </batcher.Subscribe>
26
- */
27
- Subscribe: <TSelected>(props: {
28
- selector: (state: BatcherState<TValue>) => TSelected;
29
- children: ((state: Accessor<TSelected>) => JSX.Element) | JSX.Element;
30
- }) => JSX.Element;
31
- /**
32
- * Reactive state that will be updated when the batcher state changes
33
- *
34
- * Use this instead of `batcher.store.state`
35
- */
36
- readonly state: Accessor<Readonly<TSelected>>;
37
- /**
38
- * @deprecated Use `batcher.state` instead of `batcher.store.state` if you want to read reactive state.
39
- * The state on the store object is not reactive, as it has not been wrapped in a `useSelector` hook internally.
40
- * Although, you can make the state reactive by using the `useSelector` in your own usage.
41
- */
42
- readonly store: Store<Readonly<BatcherState<TValue>>>;
43
- }
44
- /**
45
- * Creates a Solid-compatible Batcher instance for managing batches of items, exposing Solid signals for all stateful properties.
46
- *
47
- * Features:
48
- * - Batch processing of items using the provided `fn` function
49
- * - Configurable batch size and wait time
50
- * - Custom batch processing logic via getShouldExecute
51
- * - Event callbacks for monitoring batch operations
52
- * - All stateful properties (items, counts, etc.) are exposed as Solid signals for reactivity
53
- *
54
- * The batcher collects items and processes them in batches based on:
55
- * - Maximum batch size
56
- * - Time-based batching (process after X milliseconds)
57
- * - Custom batch processing logic via getShouldExecute
58
- *
59
- * ## State Management and Selector
60
- *
61
- * The hook uses TanStack Store for reactive state management. You can subscribe to state changes
62
- * in two ways:
63
- *
64
- * **1. Using `batcher.Subscribe` component (Recommended for component tree subscriptions)**
65
- *
66
- * Use the `Subscribe` component to subscribe to state changes deep in your component tree without
67
- * needing to pass a selector to the hook. This is ideal when you want to subscribe to state
68
- * in child components.
69
- *
70
- * **2. Using the `selector` parameter (For hook-level subscriptions)**
71
- *
72
- * The `selector` parameter allows you to specify which state changes will trigger reactive updates
73
- * at the hook level, optimizing performance by preventing unnecessary updates when irrelevant
74
- * state changes occur.
75
- *
76
- * **By default, there will be no reactive state subscriptions** and you must opt-in to state
77
- * tracking by providing a selector function or using the `Subscribe` component. This prevents unnecessary
78
- * updates and gives you full control over when your component tracks state changes.
79
- *
80
- * Available state properties:
81
- * - `executionCount`: Number of batch executions that have been completed
82
- * - `isRunning`: Whether the batcher is currently running (not stopped)
83
- * - `items`: Array of items currently queued for batching
84
- * - `totalItemsProcessed`: Total number of individual items that have been processed across all batches
85
- *
86
- * ## Unmount behavior
87
- *
88
- * By default, the primitive cancels any pending batch when the owning component unmounts.
89
- * Use the `onUnmount` option to customize this. For example, to flush pending work instead:
90
- *
91
- * ```tsx
92
- * const batcher = createBatcher(fn, {
93
- * maxSize: 10,
94
- * wait: 2000,
95
- * onUnmount: (b) => b.flush()
96
- * });
97
- * ```
98
- *
99
- * Example usage:
100
- * ```tsx
101
- * // Default behavior - no reactive state subscriptions
102
- * const batcher = createBatcher(
103
- * (items) => {
104
- * // Process batch of items
105
- * console.log('Processing batch:', items);
106
- * },
107
- * {
108
- * maxSize: 5,
109
- * wait: 2000,
110
- * onExecute: (batcher) => console.log('Batch executed'),
111
- * getShouldExecute: (items) => items.length >= 3
112
- * }
113
- * );
114
- *
115
- * // Opt-in to track items or isRunning changes (optimized for UI updates)
116
- * const batcher = createBatcher(
117
- * (items) => console.log('Processing batch:', items),
118
- * { maxSize: 5, wait: 2000 },
119
- * (state) => ({ items: state.items, isRunning: state.isRunning })
120
- * );
121
- *
122
- * // Opt-in to track execution metrics changes (optimized for tracking progress)
123
- * const batcher = createBatcher(
124
- * (items) => console.log('Processing batch:', items),
125
- * { maxSize: 5, wait: 2000 },
126
- * (state) => ({
127
- * executionCount: state.executionCount,
128
- * totalItemsProcessed: state.totalItemsProcessed
129
- * })
130
- * );
131
- *
132
- * // Add items to batch
133
- * batcher.addItem('task1');
134
- * batcher.addItem('task2');
135
- *
136
- * // Control the batcher
137
- * batcher.stop(); // Pause processing
138
- * batcher.start(); // Resume processing
139
- *
140
- * // Access the selected state (will be empty object {} unless selector provided)
141
- * const { items, isRunning } = batcher.state();
142
- * ```
143
- */
144
- declare function createBatcher<TValue, TSelected = {}>(fn: (items: Array<TValue>) => void, options?: SolidBatcherOptions<TValue, TSelected>, selector?: (state: BatcherState<TValue>) => TSelected): SolidBatcher<TValue, TSelected>;
145
- //#endregion
146
- export { SolidBatcher, SolidBatcherOptions, createBatcher };
147
- //# sourceMappingURL=createBatcher.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createBatcher.js","names":[],"sources":["../../src/batcher/createBatcher.ts"],"sourcesContent":["import { Batcher } from '@tanstack/pacer/batcher'\nimport { shallow, useSelector } 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, JSX } from 'solid-js'\nimport type { BatcherOptions, BatcherState } from '@tanstack/pacer/batcher'\n\nexport interface SolidBatcherOptions<\n TValue,\n TSelected = {},\n> extends BatcherOptions<TValue> {\n /**\n * Optional callback invoked when the owning component unmounts. Receives the batcher instance.\n * When provided, replaces the default cleanup (cancel); use it to call flush(), reset(), cancel(), add logging, etc.\n */\n onUnmount?: (batcher: SolidBatcher<TValue, TSelected>) => void\n}\n\nexport interface SolidBatcher<TValue, TSelected = {}> extends Omit<\n Batcher<TValue>,\n 'store'\n> {\n /**\n * A Solid component that allows you to subscribe to the batcher state.\n *\n * This is useful for tracking specific parts of the batcher state\n * deep in your component tree without needing to pass a selector to the hook.\n *\n * @example\n * <batcher.Subscribe selector={(state) => ({ size: state.size, isRunning: state.isRunning })}>\n * {(state) => (\n * <div>Batch: {state().size} items, {state().isRunning ? 'Processing' : 'Idle'}</div>\n * )}\n * </batcher.Subscribe>\n */\n Subscribe: <TSelected>(props: {\n selector: (state: BatcherState<TValue>) => TSelected\n children: ((state: Accessor<TSelected>) => JSX.Element) | JSX.Element\n }) => JSX.Element\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 `useSelector` hook internally.\n * Although, you can make the state reactive by using the `useSelector` in your own usage.\n */\n readonly store: Store<Readonly<BatcherState<TValue>>>\n}\n\n/**\n * Creates a Solid-compatible Batcher instance for managing batches of items, exposing Solid signals for all stateful properties.\n *\n * Features:\n * - Batch processing of items using the provided `fn` function\n * - Configurable batch size and wait time\n * - Custom batch processing logic via getShouldExecute\n * - Event callbacks for monitoring batch operations\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\n * - Time-based batching (process after X milliseconds)\n * - Custom batch processing logic via getShouldExecute\n *\n * ## State Management and Selector\n *\n * The hook uses TanStack Store for reactive state management. You can subscribe to state changes\n * in two ways:\n *\n * **1. Using `batcher.Subscribe` component (Recommended for component tree subscriptions)**\n *\n * Use the `Subscribe` component to subscribe to state changes deep in your component tree without\n * needing to pass a selector to the hook. This is ideal when you want to subscribe to state\n * in child components.\n *\n * **2. Using the `selector` parameter (For hook-level subscriptions)**\n *\n * The `selector` parameter allows you to specify which state changes will trigger reactive updates\n * at the hook level, optimizing performance by preventing unnecessary updates when irrelevant\n * 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 or using the `Subscribe` component. This prevents unnecessary\n * updates and gives you full control over when your component tracks state changes.\n *\n * Available state properties:\n * - `executionCount`: Number of batch executions that have been completed\n * - `isRunning`: Whether the batcher is currently running (not stopped)\n * - `items`: Array of items currently queued for batching\n * - `totalItemsProcessed`: Total number of individual items that have been processed across all batches\n *\n * ## Unmount behavior\n *\n * By default, the primitive cancels any pending batch when the owning component unmounts.\n * Use the `onUnmount` option to customize this. For example, to flush pending work instead:\n *\n * ```tsx\n * const batcher = createBatcher(fn, {\n * maxSize: 10,\n * wait: 2000,\n * onUnmount: (b) => b.flush()\n * });\n * ```\n *\n * Example usage:\n * ```tsx\n * // Default behavior - no reactive state subscriptions\n * const batcher = createBatcher(\n * (items) => {\n * // Process batch of items\n * console.log('Processing batch:', items);\n * },\n * {\n * maxSize: 5,\n * wait: 2000,\n * onExecute: (batcher) => console.log('Batch executed'),\n * getShouldExecute: (items) => items.length >= 3\n * }\n * );\n *\n * // Opt-in to track items or isRunning changes (optimized for UI updates)\n * const batcher = createBatcher(\n * (items) => console.log('Processing batch:', items),\n * { maxSize: 5, wait: 2000 },\n * (state) => ({ items: state.items, isRunning: state.isRunning })\n * );\n *\n * // Opt-in to track execution metrics changes (optimized for tracking progress)\n * const batcher = createBatcher(\n * (items) => console.log('Processing batch:', items),\n * { maxSize: 5, wait: 2000 },\n * (state) => ({\n * executionCount: state.executionCount,\n * totalItemsProcessed: state.totalItemsProcessed\n * })\n * );\n *\n * // Add items to batch\n * batcher.addItem('task1');\n * batcher.addItem('task2');\n *\n * // Control the batcher\n * batcher.stop(); // Pause processing\n * batcher.start(); // Resume processing\n *\n * // Access the selected state (will be empty object {} unless selector provided)\n * const { items, isRunning } = batcher.state();\n * ```\n */\nexport function createBatcher<TValue, TSelected = {}>(\n fn: (items: Array<TValue>) => void,\n options: SolidBatcherOptions<TValue, TSelected> = {},\n selector: (state: BatcherState<TValue>) => TSelected = () =>\n ({}) as TSelected,\n): SolidBatcher<TValue, TSelected> {\n const mergedOptions = {\n ...useDefaultPacerOptions().batcher,\n ...options,\n } as SolidBatcherOptions<TValue, TSelected>\n const batcher = new Batcher(fn, mergedOptions) as unknown as SolidBatcher<\n TValue,\n TSelected\n >\n\n batcher.Subscribe = function Subscribe<TSelected>(props: {\n selector: (state: BatcherState<TValue>) => TSelected\n children: ((state: Accessor<TSelected>) => JSX.Element) | JSX.Element\n }) {\n const selected = useSelector(batcher.store, props.selector, {\n compare: shallow,\n })\n\n return typeof props.children === 'function'\n ? props.children(selected)\n : props.children\n }\n\n const state = useSelector(batcher.store, selector, { compare: shallow })\n\n createEffect(() => {\n onCleanup(() => {\n if (mergedOptions.onUnmount) {\n mergedOptions.onUnmount(batcher)\n } else {\n batcher.cancel()\n }\n })\n })\n\n return {\n ...batcher,\n state,\n } as SolidBatcher<TValue, TSelected>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0JA,SAAgB,cACd,IACA,UAAkD,EAAE,EACpD,kBACG,EAAE,GAC4B;CACjC,MAAM,gBAAgB;EACpB,GAAG,wBAAwB,CAAC;EAC5B,GAAG;EACJ;CACD,MAAM,UAAU,IAAI,QAAQ,IAAI,cAAc;CAK9C,QAAQ,YAAY,SAAS,UAAqB,OAG/C;EACD,MAAM,WAAW,YAAY,QAAQ,OAAO,MAAM,UAAU,EAC1D,SAAS,SACV,CAAC;EAEF,OAAO,OAAO,MAAM,aAAa,aAC7B,MAAM,SAAS,SAAS,GACxB,MAAM;;CAGZ,MAAM,QAAQ,YAAY,QAAQ,OAAO,UAAU,EAAE,SAAS,SAAS,CAAC;CAExE,mBAAmB;EACjB,gBAAgB;GACd,IAAI,cAAc,WAChB,cAAc,UAAU,QAAQ;QAEhC,QAAQ,QAAQ;IAElB;GACF;CAEF,OAAO;EACL,GAAG;EACH;EACD"}
@@ -1,11 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_createBatcher = require('./createBatcher.cjs');
3
-
4
- exports.createBatcher = require_createBatcher.createBatcher;
5
- var _tanstack_pacer_batcher = require("@tanstack/pacer/batcher");
6
- Object.keys(_tanstack_pacer_batcher).forEach(function (k) {
7
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
8
- enumerable: true,
9
- get: function () { return _tanstack_pacer_batcher[k]; }
10
- });
11
- });
@@ -1,3 +0,0 @@
1
- import { SolidBatcher, SolidBatcherOptions, createBatcher } from "./createBatcher.cjs";
2
- export * from "@tanstack/pacer/batcher";
3
- export { SolidBatcher, SolidBatcherOptions, createBatcher };
@@ -1,88 +0,0 @@
1
- const require_createDebouncer = require('./createDebouncer.cjs');
2
- let solid_js = require("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] = (0, solid_js.createSignal)(value);
78
- const debouncer = require_createDebouncer.createDebouncer(setDebouncedValue, initialOptions, selector);
79
- return [
80
- debouncedValue,
81
- debouncer.maybeExecute,
82
- debouncer
83
- ];
84
- }
85
-
86
- //#endregion
87
- exports.createDebouncedSignal = createDebouncedSignal;
88
- //# sourceMappingURL=createDebouncedSignal.cjs.map
@@ -1 +0,0 @@
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, SolidDebouncerOptions } from './createDebouncer'\nimport type { Accessor, Setter } from 'solid-js'\nimport type { DebouncerState } 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: SolidDebouncerOptions<Setter<TValue>, TSelected>,\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6EA,SAAgB,sBACd,OACA,gBACA,UAKA;CACA,MAAM,CAAC,gBAAgB,gDAA0C,MAAM;CAEvE,MAAM,YAAYA,wCAAgB,mBAAmB,gBAAgB,SAAS;CAE9E,OAAO;EAAC;EAAgB,UAAU;EAAgC;EAAU"}
@@ -1,80 +0,0 @@
1
- import { SolidDebouncer, SolidDebouncerOptions } from "./createDebouncer.cjs";
2
- import { Accessor, Setter } from "solid-js";
3
- import { DebouncerState } from "@tanstack/pacer/debouncer";
4
-
5
- //#region src/debouncer/createDebouncedSignal.d.ts
6
- /**
7
- * A Solid hook that creates a debounced state value, combining Solid's createSignal with debouncing functionality.
8
- * This hook provides both the current debounced value and methods to update it.
9
- *
10
- * The state value is only updated after the specified wait time has elapsed since the last update attempt.
11
- * If another update is attempted before the wait time expires, the timer resets and starts waiting again.
12
- * This is useful for handling frequent state updates that should be throttled, like search input values
13
- * or window resize dimensions.
14
- *
15
- * The hook returns a tuple containing:
16
- * - The current debounced value accessor
17
- * - A function to update the debounced value
18
- * - The debouncer instance with additional control methods and state signals
19
- *
20
- * ## State Management and Selector
21
- *
22
- * The hook uses TanStack Store for reactive state management via the underlying debouncer instance.
23
- * The `selector` parameter allows you to specify which debouncer state changes will trigger reactive updates,
24
- * optimizing performance by preventing unnecessary subscriptions when irrelevant state changes occur.
25
- *
26
- * **By default, there will be no reactive state subscriptions** and you must opt-in to state
27
- * tracking by providing a selector function. This prevents unnecessary reactive updates and gives you
28
- * full control over when your component subscribes to state changes. Only when you provide a selector will
29
- * the reactive system track the selected state values.
30
- *
31
- * Available debouncer state properties:
32
- * - `canLeadingExecute`: Whether the debouncer can execute on the leading edge
33
- * - `executionCount`: Number of function executions that have been completed
34
- * - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution
35
- * - `lastArgs`: The arguments from the most recent call to maybeExecute
36
- * - `status`: Current execution status ('disabled' | 'idle' | 'pending')
37
- *
38
- * @example
39
- * ```tsx
40
- * // Default behavior - no reactive state subscriptions
41
- * const [searchTerm, setSearchTerm, debouncer] = createDebouncedSignal('', {
42
- * wait: 500 // Wait 500ms after last keystroke
43
- * });
44
- *
45
- * // Opt-in to reactive updates when pending state changes (optimized for loading indicators)
46
- * const [searchTerm, setSearchTerm, debouncer] = createDebouncedSignal(
47
- * '',
48
- * { wait: 500 },
49
- * (state) => ({ isPending: state.isPending })
50
- * );
51
- *
52
- * // Opt-in to reactive updates when execution count changes (optimized for tracking executions)
53
- * const [searchTerm, setSearchTerm, debouncer] = createDebouncedSignal(
54
- * '',
55
- * { wait: 500 },
56
- * (state) => ({ executionCount: state.executionCount })
57
- * );
58
- *
59
- * // Update value - will be debounced
60
- * const handleChange = (e) => {
61
- * setSearchTerm(e.target.value);
62
- * };
63
- *
64
- * // Access debouncer state via signals
65
- * console.log('Executions:', debouncer.state().executionCount);
66
- * console.log('Is pending:', debouncer.state().isPending);
67
- *
68
- * // In onExecute callback, use get* methods
69
- * const [searchTerm, setSearchTerm, debouncer] = createDebouncedSignal('', {
70
- * wait: 500,
71
- * onExecute: (debouncer) => {
72
- * console.log('Total executions:', debouncer.getExecutionCount());
73
- * }
74
- * });
75
- * ```
76
- */
77
- declare function createDebouncedSignal<TValue, TSelected = {}>(value: TValue, initialOptions: SolidDebouncerOptions<Setter<TValue>, TSelected>, selector?: (state: DebouncerState<Setter<TValue>>) => TSelected): [Accessor<TValue>, Setter<TValue>, SolidDebouncer<Setter<TValue>, TSelected>];
78
- //#endregion
79
- export { createDebouncedSignal };
80
- //# sourceMappingURL=createDebouncedSignal.d.cts.map
@@ -1 +0,0 @@
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, SolidDebouncerOptions } from './createDebouncer'\nimport type { Accessor, Setter } from 'solid-js'\nimport type { DebouncerState } 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: SolidDebouncerOptions<Setter<TValue>, TSelected>,\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6EA,SAAgB,sBACd,OACA,gBACA,UAKA;CACA,MAAM,CAAC,gBAAgB,qBAAqB,aAAqB,MAAM;CAEvE,MAAM,YAAY,gBAAgB,mBAAmB,gBAAgB,SAAS;CAE9E,OAAO;EAAC;EAAgB,UAAU;EAAgC;EAAU"}
@@ -1,77 +0,0 @@
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
@@ -1 +0,0 @@
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, SolidDebouncerOptions } from './createDebouncer'\nimport type { Accessor, Setter } from 'solid-js'\nimport type { DebouncerState } 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: SolidDebouncerOptions<Setter<TValue>, TSelected>,\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,SAAgB,qBACd,OACA,gBACA,UAC+D;CAC/D,MAAM,CAAC,gBAAgB,mBAAmB,aAAaA,oDACrD,OAAO,EACP,gBACA,SACD;CAED,iCAAmB;EACjB,kBAAkB,OAAO,CAAQ;GACjC;CAEF,OAAO,CAAC,gBAAgB,UAAU"}
@@ -1,71 +0,0 @@
1
- import { SolidDebouncer, SolidDebouncerOptions } from "./createDebouncer.cjs";
2
- import { Accessor, Setter } from "solid-js";
3
- import { DebouncerState } from "@tanstack/pacer/debouncer";
4
-
5
- //#region src/debouncer/createDebouncedValue.d.ts
6
- /**
7
- * A Solid hook that creates a debounced value that updates only after a specified delay.
8
- * Unlike createDebouncedSignal, this hook automatically tracks changes to the input value
9
- * and updates the debounced value accordingly.
10
- *
11
- * The debounced value will only update after the specified wait time has elapsed since
12
- * the last change to the input value. If the input value changes again before the wait
13
- * time expires, the timer resets and starts waiting again.
14
- *
15
- * This is useful for deriving debounced values from props or state that change frequently,
16
- * like search queries or form inputs, where you want to limit how often downstream effects
17
- * or calculations occur.
18
- *
19
- * The hook returns a tuple containing:
20
- * - An Accessor that provides the current debounced value
21
- * - The debouncer instance with control methods
22
- *
23
- * ## State Management and Selector
24
- *
25
- * The hook uses TanStack Store for reactive state management via the underlying debouncer instance.
26
- * The `selector` parameter allows you to specify which debouncer state changes will trigger reactive updates,
27
- * optimizing performance by preventing unnecessary subscriptions when irrelevant state changes occur.
28
- *
29
- * **By default, there will be no reactive state subscriptions** and you must opt-in to state
30
- * tracking by providing a selector function. This prevents unnecessary reactive updates and gives you
31
- * full control over when your component subscribes to state changes. Only when you provide a selector will
32
- * the reactive system track the selected state values.
33
- *
34
- * Available debouncer state properties:
35
- * - `canLeadingExecute`: Whether the debouncer can execute on the leading edge
36
- * - `executionCount`: Number of function executions that have been completed
37
- * - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution
38
- * - `lastArgs`: The arguments from the most recent call to maybeExecute
39
- * - `status`: Current execution status ('disabled' | 'idle' | 'pending')
40
- *
41
- * @example
42
- * ```tsx
43
- * // Default behavior - no reactive state subscriptions
44
- * const [searchQuery, setSearchQuery] = createSignal('');
45
- * const [debouncedQuery, debouncer] = createDebouncedValue(searchQuery, {
46
- * wait: 500 // Wait 500ms after last change
47
- * });
48
- *
49
- * // Opt-in to reactive updates when pending state changes (optimized for loading indicators)
50
- * const [debouncedQuery, debouncer] = createDebouncedValue(
51
- * searchQuery,
52
- * { wait: 500 },
53
- * (state) => ({ isPending: state.isPending })
54
- * );
55
- *
56
- * // debouncedQuery will update 500ms after searchQuery stops changing
57
- * createEffect(() => {
58
- * fetchSearchResults(debouncedQuery());
59
- * });
60
- *
61
- * // Access debouncer state via signals
62
- * console.log('Is pending:', debouncer.state().isPending);
63
- *
64
- * // Control the debouncer
65
- * debouncer.cancel(); // Cancel any pending updates
66
- * ```
67
- */
68
- declare function createDebouncedValue<TValue, TSelected = {}>(value: Accessor<TValue>, initialOptions: SolidDebouncerOptions<Setter<TValue>, TSelected>, selector?: (state: DebouncerState<Setter<TValue>>) => TSelected): [Accessor<TValue>, SolidDebouncer<Setter<TValue>, TSelected>];
69
- //#endregion
70
- export { createDebouncedValue };
71
- //# sourceMappingURL=createDebouncedValue.d.cts.map
@@ -1 +0,0 @@
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, SolidDebouncerOptions } from './createDebouncer'\nimport type { Accessor, Setter } from 'solid-js'\nimport type { DebouncerState } 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: SolidDebouncerOptions<Setter<TValue>, TSelected>,\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,SAAgB,qBACd,OACA,gBACA,UAC+D;CAC/D,MAAM,CAAC,gBAAgB,mBAAmB,aAAa,sBACrD,OAAO,EACP,gBACA,SACD;CAED,mBAAmB;EACjB,kBAAkB,OAAO,CAAQ;GACjC;CAEF,OAAO,CAAC,gBAAgB,UAAU"}