@tanstack/angular-pacer 0.23.1 → 0.25.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 (250) hide show
  1. package/README.md +21 -6
  2. package/dist/async-batcher/injectAsyncBatchedCallback.d.ts +2 -5
  3. package/dist/async-batcher/injectAsyncBatchedCallback.js +1 -2
  4. package/dist/async-batcher/injectAsyncBatcher.d.ts +4 -7
  5. package/dist/async-batcher/injectAsyncBatcher.js +1 -2
  6. package/dist/async-debouncer/injectAsyncDebouncedCallback.d.ts +2 -5
  7. package/dist/async-debouncer/injectAsyncDebouncedCallback.js +1 -2
  8. package/dist/async-debouncer/injectAsyncDebouncer.d.ts +4 -7
  9. package/dist/async-debouncer/injectAsyncDebouncer.js +1 -2
  10. package/dist/async-queuer/injectAsyncQueuedSignal.d.ts +3 -6
  11. package/dist/async-queuer/injectAsyncQueuedSignal.js +1 -2
  12. package/dist/async-queuer/injectAsyncQueuer.d.ts +4 -7
  13. package/dist/async-queuer/injectAsyncQueuer.js +1 -2
  14. package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.d.ts +2 -5
  15. package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.js +1 -2
  16. package/dist/async-rate-limiter/injectAsyncRateLimiter.d.ts +4 -7
  17. package/dist/async-rate-limiter/injectAsyncRateLimiter.js +1 -2
  18. package/dist/async-throttler/injectAsyncThrottledCallback.d.ts +2 -5
  19. package/dist/async-throttler/injectAsyncThrottledCallback.js +1 -2
  20. package/dist/async-throttler/injectAsyncThrottler.d.ts +4 -7
  21. package/dist/async-throttler/injectAsyncThrottler.js +1 -2
  22. package/dist/batcher/injectBatchedCallback.d.ts +2 -5
  23. package/dist/batcher/injectBatchedCallback.js +1 -2
  24. package/dist/batcher/injectBatcher.d.ts +4 -7
  25. package/dist/batcher/injectBatcher.js +1 -2
  26. package/dist/debouncer/injectDebouncedCallback.d.ts +2 -5
  27. package/dist/debouncer/injectDebouncedCallback.js +1 -2
  28. package/dist/debouncer/injectDebouncedSignal.d.ts +3 -6
  29. package/dist/debouncer/injectDebouncedSignal.js +1 -2
  30. package/dist/debouncer/injectDebouncedValue.d.ts +3 -6
  31. package/dist/debouncer/injectDebouncedValue.js +1 -2
  32. package/dist/debouncer/injectDebouncer.d.ts +4 -7
  33. package/dist/debouncer/injectDebouncer.js +1 -2
  34. package/dist/provider/pacer-context.d.ts +4 -7
  35. package/dist/provider/pacer-context.js +1 -2
  36. package/dist/provider/pacer-provider.d.ts +2 -5
  37. package/dist/provider/pacer-provider.js +1 -2
  38. package/dist/queuer/injectQueuedSignal.d.ts +3 -6
  39. package/dist/queuer/injectQueuedSignal.js +1 -2
  40. package/dist/queuer/injectQueuedValue.d.ts +3 -6
  41. package/dist/queuer/injectQueuedValue.js +1 -2
  42. package/dist/queuer/injectQueuer.d.ts +4 -7
  43. package/dist/queuer/injectQueuer.js +1 -2
  44. package/dist/rate-limiter/injectRateLimitedCallback.d.ts +2 -5
  45. package/dist/rate-limiter/injectRateLimitedCallback.js +1 -2
  46. package/dist/rate-limiter/injectRateLimitedSignal.d.ts +3 -6
  47. package/dist/rate-limiter/injectRateLimitedSignal.js +1 -2
  48. package/dist/rate-limiter/injectRateLimitedValue.d.ts +3 -6
  49. package/dist/rate-limiter/injectRateLimitedValue.js +1 -2
  50. package/dist/rate-limiter/injectRateLimiter.d.ts +4 -7
  51. package/dist/rate-limiter/injectRateLimiter.js +1 -2
  52. package/dist/throttler/injectThrottledCallback.d.ts +2 -5
  53. package/dist/throttler/injectThrottledCallback.js +1 -2
  54. package/dist/throttler/injectThrottledSignal.d.ts +3 -8
  55. package/dist/throttler/injectThrottledSignal.js +1 -4
  56. package/dist/throttler/injectThrottledValue.d.ts +3 -8
  57. package/dist/throttler/injectThrottledValue.js +1 -2
  58. package/dist/throttler/injectThrottler.d.ts +4 -9
  59. package/dist/throttler/injectThrottler.js +1 -4
  60. package/package.json +25 -72
  61. package/dist/async-batcher/index.cjs +0 -13
  62. package/dist/async-batcher/index.d.cts +0 -4
  63. package/dist/async-batcher/injectAsyncBatchedCallback.cjs +0 -49
  64. package/dist/async-batcher/injectAsyncBatchedCallback.cjs.map +0 -1
  65. package/dist/async-batcher/injectAsyncBatchedCallback.d.cts +0 -45
  66. package/dist/async-batcher/injectAsyncBatchedCallback.js.map +0 -1
  67. package/dist/async-batcher/injectAsyncBatcher.cjs +0 -85
  68. package/dist/async-batcher/injectAsyncBatcher.cjs.map +0 -1
  69. package/dist/async-batcher/injectAsyncBatcher.d.cts +0 -85
  70. package/dist/async-batcher/injectAsyncBatcher.js.map +0 -1
  71. package/dist/async-debouncer/index.cjs +0 -13
  72. package/dist/async-debouncer/index.d.cts +0 -4
  73. package/dist/async-debouncer/injectAsyncDebouncedCallback.cjs +0 -49
  74. package/dist/async-debouncer/injectAsyncDebouncedCallback.cjs.map +0 -1
  75. package/dist/async-debouncer/injectAsyncDebouncedCallback.d.cts +0 -43
  76. package/dist/async-debouncer/injectAsyncDebouncedCallback.js.map +0 -1
  77. package/dist/async-debouncer/injectAsyncDebouncer.cjs +0 -107
  78. package/dist/async-debouncer/injectAsyncDebouncer.cjs.map +0 -1
  79. package/dist/async-debouncer/injectAsyncDebouncer.d.cts +0 -108
  80. package/dist/async-debouncer/injectAsyncDebouncer.js.map +0 -1
  81. package/dist/async-queuer/index.cjs +0 -13
  82. package/dist/async-queuer/index.d.cts +0 -4
  83. package/dist/async-queuer/injectAsyncQueuedSignal.cjs +0 -53
  84. package/dist/async-queuer/injectAsyncQueuedSignal.cjs.map +0 -1
  85. package/dist/async-queuer/injectAsyncQueuedSignal.d.cts +0 -50
  86. package/dist/async-queuer/injectAsyncQueuedSignal.js.map +0 -1
  87. package/dist/async-queuer/injectAsyncQueuer.cjs +0 -85
  88. package/dist/async-queuer/injectAsyncQueuer.cjs.map +0 -1
  89. package/dist/async-queuer/injectAsyncQueuer.d.cts +0 -85
  90. package/dist/async-queuer/injectAsyncQueuer.js.map +0 -1
  91. package/dist/async-rate-limiter/index.cjs +0 -13
  92. package/dist/async-rate-limiter/index.d.cts +0 -4
  93. package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.cjs +0 -52
  94. package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.cjs.map +0 -1
  95. package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.d.cts +0 -46
  96. package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.js.map +0 -1
  97. package/dist/async-rate-limiter/injectAsyncRateLimiter.cjs +0 -69
  98. package/dist/async-rate-limiter/injectAsyncRateLimiter.cjs.map +0 -1
  99. package/dist/async-rate-limiter/injectAsyncRateLimiter.d.cts +0 -72
  100. package/dist/async-rate-limiter/injectAsyncRateLimiter.js.map +0 -1
  101. package/dist/async-retryer/index.cjs +0 -9
  102. package/dist/async-retryer/index.d.cts +0 -1
  103. package/dist/async-throttler/index.cjs +0 -13
  104. package/dist/async-throttler/index.d.cts +0 -4
  105. package/dist/async-throttler/injectAsyncThrottledCallback.cjs +0 -50
  106. package/dist/async-throttler/injectAsyncThrottledCallback.cjs.map +0 -1
  107. package/dist/async-throttler/injectAsyncThrottledCallback.d.cts +0 -44
  108. package/dist/async-throttler/injectAsyncThrottledCallback.js.map +0 -1
  109. package/dist/async-throttler/injectAsyncThrottler.cjs +0 -86
  110. package/dist/async-throttler/injectAsyncThrottler.cjs.map +0 -1
  111. package/dist/async-throttler/injectAsyncThrottler.d.cts +0 -87
  112. package/dist/async-throttler/injectAsyncThrottler.js.map +0 -1
  113. package/dist/batcher/index.cjs +0 -13
  114. package/dist/batcher/index.d.cts +0 -4
  115. package/dist/batcher/injectBatchedCallback.cjs +0 -47
  116. package/dist/batcher/injectBatchedCallback.cjs.map +0 -1
  117. package/dist/batcher/injectBatchedCallback.d.cts +0 -43
  118. package/dist/batcher/injectBatchedCallback.js.map +0 -1
  119. package/dist/batcher/injectBatcher.cjs +0 -75
  120. package/dist/batcher/injectBatcher.cjs.map +0 -1
  121. package/dist/batcher/injectBatcher.d.cts +0 -77
  122. package/dist/batcher/injectBatcher.js.map +0 -1
  123. package/dist/debouncer/index.cjs +0 -17
  124. package/dist/debouncer/index.d.cts +0 -6
  125. package/dist/debouncer/injectDebouncedCallback.cjs +0 -46
  126. package/dist/debouncer/injectDebouncedCallback.cjs.map +0 -1
  127. package/dist/debouncer/injectDebouncedCallback.d.cts +0 -43
  128. package/dist/debouncer/injectDebouncedCallback.js.map +0 -1
  129. package/dist/debouncer/injectDebouncedSignal.cjs +0 -68
  130. package/dist/debouncer/injectDebouncedSignal.cjs.map +0 -1
  131. package/dist/debouncer/injectDebouncedSignal.d.cts +0 -60
  132. package/dist/debouncer/injectDebouncedSignal.js.map +0 -1
  133. package/dist/debouncer/injectDebouncedValue.cjs +0 -17
  134. package/dist/debouncer/injectDebouncedValue.cjs.map +0 -1
  135. package/dist/debouncer/injectDebouncedValue.d.cts +0 -76
  136. package/dist/debouncer/injectDebouncedValue.js.map +0 -1
  137. package/dist/debouncer/injectDebouncer.cjs +0 -95
  138. package/dist/debouncer/injectDebouncer.cjs.map +0 -1
  139. package/dist/debouncer/injectDebouncer.d.cts +0 -98
  140. package/dist/debouncer/injectDebouncer.js.map +0 -1
  141. package/dist/index.cjs +0 -65
  142. package/dist/index.d.cts +0 -30
  143. package/dist/provider/index.cjs +0 -7
  144. package/dist/provider/index.d.cts +0 -3
  145. package/dist/provider/pacer-context.cjs +0 -20
  146. package/dist/provider/pacer-context.cjs.map +0 -1
  147. package/dist/provider/pacer-context.d.cts +0 -21
  148. package/dist/provider/pacer-context.js.map +0 -1
  149. package/dist/provider/pacer-provider.cjs +0 -41
  150. package/dist/provider/pacer-provider.cjs.map +0 -1
  151. package/dist/provider/pacer-provider.d.cts +0 -36
  152. package/dist/provider/pacer-provider.js.map +0 -1
  153. package/dist/queuer/index.cjs +0 -15
  154. package/dist/queuer/index.d.cts +0 -5
  155. package/dist/queuer/injectQueuedSignal.cjs +0 -47
  156. package/dist/queuer/injectQueuedSignal.cjs.map +0 -1
  157. package/dist/queuer/injectQueuedSignal.d.cts +0 -44
  158. package/dist/queuer/injectQueuedSignal.js.map +0 -1
  159. package/dist/queuer/injectQueuedValue.cjs +0 -23
  160. package/dist/queuer/injectQueuedValue.cjs.map +0 -1
  161. package/dist/queuer/injectQueuedValue.d.cts +0 -34
  162. package/dist/queuer/injectQueuedValue.js.map +0 -1
  163. package/dist/queuer/injectQueuer.cjs +0 -80
  164. package/dist/queuer/injectQueuer.cjs.map +0 -1
  165. package/dist/queuer/injectQueuer.d.cts +0 -82
  166. package/dist/queuer/injectQueuer.js.map +0 -1
  167. package/dist/rate-limiter/index.cjs +0 -17
  168. package/dist/rate-limiter/index.d.cts +0 -6
  169. package/dist/rate-limiter/injectRateLimitedCallback.cjs +0 -45
  170. package/dist/rate-limiter/injectRateLimitedCallback.cjs.map +0 -1
  171. package/dist/rate-limiter/injectRateLimitedCallback.d.cts +0 -42
  172. package/dist/rate-limiter/injectRateLimitedCallback.js.map +0 -1
  173. package/dist/rate-limiter/injectRateLimitedSignal.cjs +0 -62
  174. package/dist/rate-limiter/injectRateLimitedSignal.cjs.map +0 -1
  175. package/dist/rate-limiter/injectRateLimitedSignal.d.cts +0 -54
  176. package/dist/rate-limiter/injectRateLimitedSignal.js.map +0 -1
  177. package/dist/rate-limiter/injectRateLimitedValue.cjs +0 -17
  178. package/dist/rate-limiter/injectRateLimitedValue.cjs.map +0 -1
  179. package/dist/rate-limiter/injectRateLimitedValue.d.cts +0 -49
  180. package/dist/rate-limiter/injectRateLimitedValue.js.map +0 -1
  181. package/dist/rate-limiter/injectRateLimiter.cjs +0 -100
  182. package/dist/rate-limiter/injectRateLimiter.cjs.map +0 -1
  183. package/dist/rate-limiter/injectRateLimiter.d.cts +0 -103
  184. package/dist/rate-limiter/injectRateLimiter.js.map +0 -1
  185. package/dist/throttler/index.cjs +0 -17
  186. package/dist/throttler/index.d.cts +0 -6
  187. package/dist/throttler/injectThrottledCallback.cjs +0 -45
  188. package/dist/throttler/injectThrottledCallback.cjs.map +0 -1
  189. package/dist/throttler/injectThrottledCallback.d.cts +0 -42
  190. package/dist/throttler/injectThrottledCallback.js.map +0 -1
  191. package/dist/throttler/injectThrottledSignal.cjs +0 -69
  192. package/dist/throttler/injectThrottledSignal.cjs.map +0 -1
  193. package/dist/throttler/injectThrottledSignal.d.cts +0 -61
  194. package/dist/throttler/injectThrottledSignal.js.map +0 -1
  195. package/dist/throttler/injectThrottledValue.cjs +0 -17
  196. package/dist/throttler/injectThrottledValue.cjs.map +0 -1
  197. package/dist/throttler/injectThrottledValue.d.cts +0 -74
  198. package/dist/throttler/injectThrottledValue.js.map +0 -1
  199. package/dist/throttler/injectThrottler.cjs +0 -95
  200. package/dist/throttler/injectThrottler.cjs.map +0 -1
  201. package/dist/throttler/injectThrottler.d.cts +0 -98
  202. package/dist/throttler/injectThrottler.js.map +0 -1
  203. package/dist/types/index.cjs +0 -9
  204. package/dist/types/index.d.cts +0 -1
  205. package/dist/utils/index.cjs +0 -9
  206. package/dist/utils/index.d.cts +0 -1
  207. package/src/async-batcher/index.ts +0 -4
  208. package/src/async-batcher/injectAsyncBatchedCallback.ts +0 -48
  209. package/src/async-batcher/injectAsyncBatcher.ts +0 -126
  210. package/src/async-debouncer/index.ts +0 -4
  211. package/src/async-debouncer/injectAsyncDebouncedCallback.ts +0 -50
  212. package/src/async-debouncer/injectAsyncDebouncer.ts +0 -152
  213. package/src/async-queuer/index.ts +0 -4
  214. package/src/async-queuer/injectAsyncQueuedSignal.ts +0 -74
  215. package/src/async-queuer/injectAsyncQueuer.ts +0 -126
  216. package/src/async-rate-limiter/index.ts +0 -4
  217. package/src/async-rate-limiter/injectAsyncRateLimitedCallback.ts +0 -52
  218. package/src/async-rate-limiter/injectAsyncRateLimiter.ts +0 -115
  219. package/src/async-retryer/index.ts +0 -1
  220. package/src/async-throttler/index.ts +0 -4
  221. package/src/async-throttler/injectAsyncThrottledCallback.ts +0 -50
  222. package/src/async-throttler/injectAsyncThrottler.ts +0 -131
  223. package/src/batcher/index.ts +0 -4
  224. package/src/batcher/injectBatchedCallback.ts +0 -46
  225. package/src/batcher/injectBatcher.ts +0 -114
  226. package/src/debouncer/index.ts +0 -6
  227. package/src/debouncer/injectDebouncedCallback.ts +0 -46
  228. package/src/debouncer/injectDebouncedSignal.ts +0 -94
  229. package/src/debouncer/injectDebouncedValue.ts +0 -126
  230. package/src/debouncer/injectDebouncer.ts +0 -137
  231. package/src/index.ts +0 -40
  232. package/src/provider/index.ts +0 -2
  233. package/src/provider/pacer-context.ts +0 -46
  234. package/src/provider/pacer-provider.ts +0 -38
  235. package/src/queuer/index.ts +0 -5
  236. package/src/queuer/injectQueuedSignal.ts +0 -65
  237. package/src/queuer/injectQueuedValue.ts +0 -101
  238. package/src/queuer/injectQueuer.ts +0 -118
  239. package/src/rate-limiter/index.ts +0 -6
  240. package/src/rate-limiter/injectRateLimitedCallback.ts +0 -45
  241. package/src/rate-limiter/injectRateLimitedSignal.ts +0 -88
  242. package/src/rate-limiter/injectRateLimitedValue.ts +0 -99
  243. package/src/rate-limiter/injectRateLimiter.ts +0 -140
  244. package/src/throttler/index.ts +0 -6
  245. package/src/throttler/injectThrottledCallback.ts +0 -45
  246. package/src/throttler/injectThrottledSignal.ts +0 -95
  247. package/src/throttler/injectThrottledValue.ts +0 -124
  248. package/src/throttler/injectThrottler.ts +0 -137
  249. package/src/types/index.ts +0 -1
  250. package/src/utils/index.ts +0 -1
@@ -1,17 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_injectDebouncer = require('./injectDebouncer.cjs');
3
- const require_injectDebouncedCallback = require('./injectDebouncedCallback.cjs');
4
- const require_injectDebouncedSignal = require('./injectDebouncedSignal.cjs');
5
- const require_injectDebouncedValue = require('./injectDebouncedValue.cjs');
6
-
7
- exports.injectDebouncedCallback = require_injectDebouncedCallback.injectDebouncedCallback;
8
- exports.injectDebouncedSignal = require_injectDebouncedSignal.injectDebouncedSignal;
9
- exports.injectDebouncedValue = require_injectDebouncedValue.injectDebouncedValue;
10
- exports.injectDebouncer = require_injectDebouncer.injectDebouncer;
11
- var _tanstack_pacer_debouncer = require("@tanstack/pacer/debouncer");
12
- Object.keys(_tanstack_pacer_debouncer).forEach(function (k) {
13
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
14
- enumerable: true,
15
- get: function () { return _tanstack_pacer_debouncer[k]; }
16
- });
17
- });
@@ -1,6 +0,0 @@
1
- import { injectDebouncedCallback } from "./injectDebouncedCallback.cjs";
2
- import { AngularDebouncer, AngularDebouncerOptions, injectDebouncer } from "./injectDebouncer.cjs";
3
- import { DebouncedSignal, injectDebouncedSignal } from "./injectDebouncedSignal.cjs";
4
- import { injectDebouncedValue } from "./injectDebouncedValue.cjs";
5
- export * from "@tanstack/pacer/debouncer";
6
- export { AngularDebouncer, AngularDebouncerOptions, DebouncedSignal, injectDebouncedCallback, injectDebouncedSignal, injectDebouncedValue, injectDebouncer };
@@ -1,46 +0,0 @@
1
- const require_injectDebouncer = require('./injectDebouncer.cjs');
2
-
3
- //#region src/debouncer/injectDebouncedCallback.ts
4
- /**
5
- * An Angular function that creates a debounced version of a callback function.
6
- * This function is essentially a wrapper around `injectDebouncer` that provides
7
- * a simplified API for basic debouncing needs.
8
- *
9
- * The debounced function will only execute after the specified wait time has elapsed
10
- * since its last invocation. If called again before the wait time expires, the timer
11
- * resets and starts waiting again.
12
- *
13
- * This function provides a simpler API compared to `injectDebouncer`, making it ideal for basic
14
- * debouncing needs. However, it does not expose the underlying Debouncer instance.
15
- *
16
- * For advanced usage requiring features like:
17
- * - Manual cancellation
18
- * - Access to execution counts
19
- * - State tracking
20
- *
21
- * Consider using the `injectDebouncer` function instead.
22
- *
23
- * @example
24
- * ```ts
25
- * // Debounce a search handler
26
- * const handleSearch = injectDebouncedCallback((query: string) => {
27
- * fetchSearchResults(query);
28
- * }, {
29
- * wait: 500 // Wait 500ms between executions
30
- * });
31
- *
32
- * // Use in an input
33
- * <input
34
- * type="search"
35
- * (input)="handleSearch($event.target.value)"
36
- * />
37
- * ```
38
- */
39
- function injectDebouncedCallback(fn, options) {
40
- const debouncer = require_injectDebouncer.injectDebouncer(fn, options);
41
- return (...args) => debouncer.maybeExecute(...args);
42
- }
43
-
44
- //#endregion
45
- exports.injectDebouncedCallback = injectDebouncedCallback;
46
- //# sourceMappingURL=injectDebouncedCallback.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectDebouncedCallback.cjs","names":["injectDebouncer"],"sources":["../../src/debouncer/injectDebouncedCallback.ts"],"sourcesContent":["import { injectDebouncer } from './injectDebouncer'\nimport type { DebouncerOptions } from '@tanstack/pacer/debouncer'\nimport type { AnyFunction } from '@tanstack/pacer/types'\n\n/**\n * An Angular function that creates a debounced version of a callback function.\n * This function is essentially a wrapper around `injectDebouncer` that provides\n * a simplified API for basic debouncing needs.\n *\n * The debounced function will only execute after the specified wait time has elapsed\n * since its last invocation. If called again before the wait time expires, the timer\n * resets and starts waiting again.\n *\n * This function provides a simpler API compared to `injectDebouncer`, making it ideal for basic\n * debouncing needs. However, it does not expose the underlying Debouncer instance.\n *\n * For advanced usage requiring features like:\n * - Manual cancellation\n * - Access to execution counts\n * - State tracking\n *\n * Consider using the `injectDebouncer` function instead.\n *\n * @example\n * ```ts\n * // Debounce a search handler\n * const handleSearch = injectDebouncedCallback((query: string) => {\n * fetchSearchResults(query);\n * }, {\n * wait: 500 // Wait 500ms between executions\n * });\n *\n * // Use in an input\n * <input\n * type=\"search\"\n * (input)=\"handleSearch($event.target.value)\"\n * />\n * ```\n */\nexport function injectDebouncedCallback<TFn extends AnyFunction>(\n fn: TFn,\n options: DebouncerOptions<TFn>,\n): (...args: Parameters<TFn>) => void {\n const debouncer = injectDebouncer(fn, options)\n return (...args: Parameters<TFn>) => debouncer.maybeExecute(...args)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,wBACd,IACA,SACoC;CACpC,MAAM,YAAYA,wCAAgB,IAAI,QAAQ;CAC9C,QAAQ,GAAG,SAA0B,UAAU,aAAa,GAAG,KAAK"}
@@ -1,43 +0,0 @@
1
- import { AnyFunction } from "@tanstack/pacer/types";
2
- import { DebouncerOptions } from "@tanstack/pacer/debouncer";
3
-
4
- //#region src/debouncer/injectDebouncedCallback.d.ts
5
- /**
6
- * An Angular function that creates a debounced version of a callback function.
7
- * This function is essentially a wrapper around `injectDebouncer` that provides
8
- * a simplified API for basic debouncing needs.
9
- *
10
- * The debounced function will only execute after the specified wait time has elapsed
11
- * since its last invocation. If called again before the wait time expires, the timer
12
- * resets and starts waiting again.
13
- *
14
- * This function provides a simpler API compared to `injectDebouncer`, making it ideal for basic
15
- * debouncing needs. However, it does not expose the underlying Debouncer instance.
16
- *
17
- * For advanced usage requiring features like:
18
- * - Manual cancellation
19
- * - Access to execution counts
20
- * - State tracking
21
- *
22
- * Consider using the `injectDebouncer` function instead.
23
- *
24
- * @example
25
- * ```ts
26
- * // Debounce a search handler
27
- * const handleSearch = injectDebouncedCallback((query: string) => {
28
- * fetchSearchResults(query);
29
- * }, {
30
- * wait: 500 // Wait 500ms between executions
31
- * });
32
- *
33
- * // Use in an input
34
- * <input
35
- * type="search"
36
- * (input)="handleSearch($event.target.value)"
37
- * />
38
- * ```
39
- */
40
- declare function injectDebouncedCallback<TFn extends AnyFunction>(fn: TFn, options: DebouncerOptions<TFn>): (...args: Parameters<TFn>) => void;
41
- //#endregion
42
- export { injectDebouncedCallback };
43
- //# sourceMappingURL=injectDebouncedCallback.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectDebouncedCallback.js","names":[],"sources":["../../src/debouncer/injectDebouncedCallback.ts"],"sourcesContent":["import { injectDebouncer } from './injectDebouncer'\nimport type { DebouncerOptions } from '@tanstack/pacer/debouncer'\nimport type { AnyFunction } from '@tanstack/pacer/types'\n\n/**\n * An Angular function that creates a debounced version of a callback function.\n * This function is essentially a wrapper around `injectDebouncer` that provides\n * a simplified API for basic debouncing needs.\n *\n * The debounced function will only execute after the specified wait time has elapsed\n * since its last invocation. If called again before the wait time expires, the timer\n * resets and starts waiting again.\n *\n * This function provides a simpler API compared to `injectDebouncer`, making it ideal for basic\n * debouncing needs. However, it does not expose the underlying Debouncer instance.\n *\n * For advanced usage requiring features like:\n * - Manual cancellation\n * - Access to execution counts\n * - State tracking\n *\n * Consider using the `injectDebouncer` function instead.\n *\n * @example\n * ```ts\n * // Debounce a search handler\n * const handleSearch = injectDebouncedCallback((query: string) => {\n * fetchSearchResults(query);\n * }, {\n * wait: 500 // Wait 500ms between executions\n * });\n *\n * // Use in an input\n * <input\n * type=\"search\"\n * (input)=\"handleSearch($event.target.value)\"\n * />\n * ```\n */\nexport function injectDebouncedCallback<TFn extends AnyFunction>(\n fn: TFn,\n options: DebouncerOptions<TFn>,\n): (...args: Parameters<TFn>) => void {\n const debouncer = injectDebouncer(fn, options)\n return (...args: Parameters<TFn>) => debouncer.maybeExecute(...args)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,wBACd,IACA,SACoC;CACpC,MAAM,YAAY,gBAAgB,IAAI,QAAQ;CAC9C,QAAQ,GAAG,SAA0B,UAAU,aAAa,GAAG,KAAK"}
@@ -1,68 +0,0 @@
1
- const require_injectDebouncer = require('./injectDebouncer.cjs');
2
- let _angular_core = require("@angular/core");
3
-
4
- //#region src/debouncer/injectDebouncedSignal.ts
5
- /**
6
- * An Angular function that creates a debounced state signal, combining Angular's signal with debouncing functionality.
7
- * This function 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 function returns a callable object:
15
- * - `debounced()`: Get the current debounced value
16
- * - `debounced.set(...)`: Set or update the debounced value (debounced via maybeExecute)
17
- * - `debounced.debouncer`: The debouncer instance with additional control methods and state signals
18
- *
19
- * ## State Management and Selector
20
- *
21
- * The function 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 signal 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 updates and gives you
27
- * full control over when your component tracks 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
- * ```ts
39
- * const debouncedQuery = injectDebouncedSignal('', { wait: 500 })
40
- *
41
- * // Get value
42
- * console.log(debouncedQuery())
43
- *
44
- * // Set/update value (debounced)
45
- * debouncedQuery.set('hello')
46
- *
47
- * // Access debouncer
48
- * console.log(debouncedQuery.debouncer.state().isPending)
49
- * ```
50
- */
51
- function injectDebouncedSignal(value, initialOptions, selector) {
52
- const debouncedValue = (0, _angular_core.signal)(value);
53
- const debouncer = require_injectDebouncer.injectDebouncer((newValue) => {
54
- if (typeof newValue === "function") debouncedValue.update(newValue);
55
- else debouncedValue.set(newValue);
56
- }, initialOptions, selector);
57
- const set = (newValue) => {
58
- debouncer.maybeExecute(newValue);
59
- };
60
- return Object.assign(() => debouncedValue(), {
61
- set,
62
- debouncer
63
- });
64
- }
65
-
66
- //#endregion
67
- exports.injectDebouncedSignal = injectDebouncedSignal;
68
- //# sourceMappingURL=injectDebouncedSignal.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectDebouncedSignal.cjs","names":["injectDebouncer"],"sources":["../../src/debouncer/injectDebouncedSignal.ts"],"sourcesContent":["import { signal } from '@angular/core'\nimport { injectDebouncer } from './injectDebouncer'\nimport type { AngularDebouncer } from './injectDebouncer'\nimport type {\n DebouncerOptions,\n DebouncerState,\n} from '@tanstack/pacer/debouncer'\n\ntype Setter<T> = (value: T | ((prev: T) => T)) => void\n\nexport interface DebouncedSignal<TValue, TSelected = {}> {\n (): TValue\n set: Setter<TValue>\n debouncer: AngularDebouncer<Setter<TValue>, TSelected>\n}\n\n/**\n * An Angular function that creates a debounced state signal, combining Angular's signal with debouncing functionality.\n * This function 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 function returns a callable object:\n * - `debounced()`: Get the current debounced value\n * - `debounced.set(...)`: Set or update the debounced value (debounced via maybeExecute)\n * - `debounced.debouncer`: The debouncer instance with additional control methods and state signals\n *\n * ## State Management and Selector\n *\n * The function 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 signal 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 updates and gives you\n * full control over when your component tracks 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 * ```ts\n * const debouncedQuery = injectDebouncedSignal('', { wait: 500 })\n *\n * // Get value\n * console.log(debouncedQuery())\n *\n * // Set/update value (debounced)\n * debouncedQuery.set('hello')\n *\n * // Access debouncer\n * console.log(debouncedQuery.debouncer.state().isPending)\n * ```\n */\nexport function injectDebouncedSignal<TValue, TSelected = {}>(\n value: TValue,\n initialOptions: DebouncerOptions<Setter<TValue>>,\n selector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): DebouncedSignal<TValue, TSelected> {\n const debouncedValue = signal<TValue>(value)\n\n const debouncer = injectDebouncer(\n (newValue: TValue | ((prev: TValue) => TValue)) => {\n if (typeof newValue === 'function') {\n debouncedValue.update(newValue as (prev: TValue) => TValue)\n } else {\n debouncedValue.set(newValue)\n }\n },\n initialOptions,\n selector,\n )\n\n const set: Setter<TValue> = (\n newValue: TValue | ((prev: TValue) => TValue),\n ) => {\n debouncer.maybeExecute(newValue)\n }\n\n const debounced = Object.assign(() => debouncedValue(), {\n set,\n debouncer,\n }) as DebouncedSignal<TValue, TSelected>\n\n return debounced\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,sBACd,OACA,gBACA,UACoC;CACpC,MAAM,2CAAgC,MAAM;CAE5C,MAAM,YAAYA,yCACf,aAAkD;EACjD,IAAI,OAAO,aAAa,YACtB,eAAe,OAAO,SAAqC;OAE3D,eAAe,IAAI,SAAS;IAGhC,gBACA,SACD;CAED,MAAM,OACJ,aACG;EACH,UAAU,aAAa,SAAS;;CAQlC,OALkB,OAAO,aAAa,gBAAgB,EAAE;EACtD;EACA;EACD,CAEe"}
@@ -1,60 +0,0 @@
1
- import { AngularDebouncer } from "./injectDebouncer.cjs";
2
- import { DebouncerOptions, DebouncerState } from "@tanstack/pacer/debouncer";
3
-
4
- //#region src/debouncer/injectDebouncedSignal.d.ts
5
- type Setter<T> = (value: T | ((prev: T) => T)) => void;
6
- interface DebouncedSignal<TValue, TSelected = {}> {
7
- (): TValue;
8
- set: Setter<TValue>;
9
- debouncer: AngularDebouncer<Setter<TValue>, TSelected>;
10
- }
11
- /**
12
- * An Angular function that creates a debounced state signal, combining Angular's signal with debouncing functionality.
13
- * This function provides both the current debounced value and methods to update it.
14
- *
15
- * The state value is only updated after the specified wait time has elapsed since the last update attempt.
16
- * If another update is attempted before the wait time expires, the timer resets and starts waiting again.
17
- * This is useful for handling frequent state updates that should be throttled, like search input values
18
- * or window resize dimensions.
19
- *
20
- * The function returns a callable object:
21
- * - `debounced()`: Get the current debounced value
22
- * - `debounced.set(...)`: Set or update the debounced value (debounced via maybeExecute)
23
- * - `debounced.debouncer`: The debouncer instance with additional control methods and state signals
24
- *
25
- * ## State Management and Selector
26
- *
27
- * The function uses TanStack Store for reactive state management via the underlying debouncer instance.
28
- * The `selector` parameter allows you to specify which debouncer state changes will trigger signal updates,
29
- * optimizing performance by preventing unnecessary subscriptions when irrelevant state changes occur.
30
- *
31
- * **By default, there will be no reactive state subscriptions** and you must opt-in to state
32
- * tracking by providing a selector function. This prevents unnecessary updates and gives you
33
- * full control over when your component tracks state changes. Only when you provide a selector will
34
- * the reactive system track the selected state values.
35
- *
36
- * Available debouncer state properties:
37
- * - `canLeadingExecute`: Whether the debouncer can execute on the leading edge
38
- * - `executionCount`: Number of function executions that have been completed
39
- * - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution
40
- * - `lastArgs`: The arguments from the most recent call to maybeExecute
41
- * - `status`: Current execution status ('disabled' | 'idle' | 'pending')
42
- *
43
- * @example
44
- * ```ts
45
- * const debouncedQuery = injectDebouncedSignal('', { wait: 500 })
46
- *
47
- * // Get value
48
- * console.log(debouncedQuery())
49
- *
50
- * // Set/update value (debounced)
51
- * debouncedQuery.set('hello')
52
- *
53
- * // Access debouncer
54
- * console.log(debouncedQuery.debouncer.state().isPending)
55
- * ```
56
- */
57
- declare function injectDebouncedSignal<TValue, TSelected = {}>(value: TValue, initialOptions: DebouncerOptions<Setter<TValue>>, selector?: (state: DebouncerState<Setter<TValue>>) => TSelected): DebouncedSignal<TValue, TSelected>;
58
- //#endregion
59
- export { DebouncedSignal, injectDebouncedSignal };
60
- //# sourceMappingURL=injectDebouncedSignal.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectDebouncedSignal.js","names":[],"sources":["../../src/debouncer/injectDebouncedSignal.ts"],"sourcesContent":["import { signal } from '@angular/core'\nimport { injectDebouncer } from './injectDebouncer'\nimport type { AngularDebouncer } from './injectDebouncer'\nimport type {\n DebouncerOptions,\n DebouncerState,\n} from '@tanstack/pacer/debouncer'\n\ntype Setter<T> = (value: T | ((prev: T) => T)) => void\n\nexport interface DebouncedSignal<TValue, TSelected = {}> {\n (): TValue\n set: Setter<TValue>\n debouncer: AngularDebouncer<Setter<TValue>, TSelected>\n}\n\n/**\n * An Angular function that creates a debounced state signal, combining Angular's signal with debouncing functionality.\n * This function 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 function returns a callable object:\n * - `debounced()`: Get the current debounced value\n * - `debounced.set(...)`: Set or update the debounced value (debounced via maybeExecute)\n * - `debounced.debouncer`: The debouncer instance with additional control methods and state signals\n *\n * ## State Management and Selector\n *\n * The function 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 signal 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 updates and gives you\n * full control over when your component tracks 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 * ```ts\n * const debouncedQuery = injectDebouncedSignal('', { wait: 500 })\n *\n * // Get value\n * console.log(debouncedQuery())\n *\n * // Set/update value (debounced)\n * debouncedQuery.set('hello')\n *\n * // Access debouncer\n * console.log(debouncedQuery.debouncer.state().isPending)\n * ```\n */\nexport function injectDebouncedSignal<TValue, TSelected = {}>(\n value: TValue,\n initialOptions: DebouncerOptions<Setter<TValue>>,\n selector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): DebouncedSignal<TValue, TSelected> {\n const debouncedValue = signal<TValue>(value)\n\n const debouncer = injectDebouncer(\n (newValue: TValue | ((prev: TValue) => TValue)) => {\n if (typeof newValue === 'function') {\n debouncedValue.update(newValue as (prev: TValue) => TValue)\n } else {\n debouncedValue.set(newValue)\n }\n },\n initialOptions,\n selector,\n )\n\n const set: Setter<TValue> = (\n newValue: TValue | ((prev: TValue) => TValue),\n ) => {\n debouncer.maybeExecute(newValue)\n }\n\n const debounced = Object.assign(() => debouncedValue(), {\n set,\n debouncer,\n }) as DebouncedSignal<TValue, TSelected>\n\n return debounced\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,sBACd,OACA,gBACA,UACoC;CACpC,MAAM,iBAAiB,OAAe,MAAM;CAE5C,MAAM,YAAY,iBACf,aAAkD;EACjD,IAAI,OAAO,aAAa,YACtB,eAAe,OAAO,SAAqC;OAE3D,eAAe,IAAI,SAAS;IAGhC,gBACA,SACD;CAED,MAAM,OACJ,aACG;EACH,UAAU,aAAa,SAAS;;CAQlC,OALkB,OAAO,aAAa,gBAAgB,EAAE;EACtD;EACA;EACD,CAEe"}
@@ -1,17 +0,0 @@
1
- const require_injectDebouncedSignal = require('./injectDebouncedSignal.cjs');
2
- let _angular_core = require("@angular/core");
3
-
4
- //#region src/debouncer/injectDebouncedValue.ts
5
- function injectDebouncedValue(value, initialValueOrOptions, initialOptionsOrSelector, maybeSelector) {
6
- const hasInitialValue = initialOptionsOrSelector !== void 0 && !(typeof initialOptionsOrSelector === "function") || maybeSelector !== void 0;
7
- const debounced = require_injectDebouncedSignal.injectDebouncedSignal(hasInitialValue ? initialValueOrOptions : void 0, hasInitialValue ? initialOptionsOrSelector : initialValueOrOptions, hasInitialValue ? maybeSelector : initialOptionsOrSelector);
8
- (0, _angular_core.effect)(() => {
9
- const latest = value();
10
- debounced.set(latest);
11
- });
12
- return debounced;
13
- }
14
-
15
- //#endregion
16
- exports.injectDebouncedValue = injectDebouncedValue;
17
- //# sourceMappingURL=injectDebouncedValue.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectDebouncedValue.cjs","names":["injectDebouncedSignal"],"sources":["../../src/debouncer/injectDebouncedValue.ts"],"sourcesContent":["import { effect } from '@angular/core'\nimport { injectDebouncedSignal } from './injectDebouncedSignal'\nimport type { DebouncedSignal } from './injectDebouncedSignal'\nimport type { Signal } from '@angular/core'\nimport type {\n DebouncerOptions,\n DebouncerState,\n} from '@tanstack/pacer/debouncer'\n\ntype Setter<T> = (value: T | ((prev: T) => T)) => void\n\n/**\n * An Angular function that creates a debounced value that updates only after a specified delay.\n * Unlike injectDebouncedSignal, this function automatically tracks changes to the input signal\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 signals 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 function returns a tuple containing:\n * - A Signal that provides the current debounced value\n * - The debouncer instance with control methods\n *\n * ## State Management and Selector\n *\n * The function 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 signal 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 updates and gives you\n * full control over when your component tracks 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 *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const searchQuery = signal('')\n * const debounced = injectDebouncedValue(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 debouncedWithPending = injectDebouncedValue(\n * searchQuery,\n * { wait: 500 },\n * (state) => ({ isPending: state.isPending }),\n * )\n *\n * // Debounced value will update 500ms after searchQuery stops changing\n * effect(() => {\n * fetchSearchResults(debounced())\n * })\n *\n * // Access selected debouncer state via signals (only if you provided a selector)\n * effect(() => {\n * console.log('Is pending:', debouncedWithPending.state().isPending)\n * })\n *\n * // Control the debouncer\n * debounced.cancel() // Cancel any pending updates\n * ```\n */\nexport function injectDebouncedValue<TValue, TSelected = {}>(\n value: Signal<TValue>,\n initialOptions: DebouncerOptions<Setter<TValue>>,\n selector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): DebouncedSignal<TValue, TSelected>\nexport function injectDebouncedValue<TValue, TSelected = {}>(\n value: Signal<TValue>,\n initialValue: TValue,\n initialOptions: DebouncerOptions<Setter<TValue>>,\n selector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): DebouncedSignal<TValue, TSelected>\nexport function injectDebouncedValue<TValue, TSelected = {}>(\n value: Signal<TValue>,\n initialValueOrOptions: TValue | DebouncerOptions<Setter<TValue>>,\n initialOptionsOrSelector?:\n | DebouncerOptions<Setter<TValue>>\n | ((state: DebouncerState<Setter<TValue>>) => TSelected),\n maybeSelector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): DebouncedSignal<TValue, TSelected> {\n const hasSelector = typeof initialOptionsOrSelector === 'function'\n\n const hasInitialValue =\n (initialOptionsOrSelector !== undefined && !hasSelector) ||\n maybeSelector !== undefined\n\n const initialValue = hasInitialValue\n ? (initialValueOrOptions as TValue)\n : (undefined as unknown as TValue)\n const initialOptions = hasInitialValue\n ? (initialOptionsOrSelector as DebouncerOptions<Setter<TValue>>)\n : (initialValueOrOptions as DebouncerOptions<Setter<TValue>>)\n const selector = hasInitialValue\n ? maybeSelector\n : (initialOptionsOrSelector as\n | ((state: DebouncerState<Setter<TValue>>) => TSelected)\n | undefined)\n\n const debounced = injectDebouncedSignal(\n initialValue,\n initialOptions,\n selector,\n )\n\n effect(() => {\n const latest = value()\n debounced.set(latest)\n })\n\n return debounced\n}\n"],"mappings":";;;;AAuFA,SAAgB,qBACd,OACA,uBACA,0BAGA,eACoC;CAGpC,MAAM,kBACH,6BAA6B,UAAa,EAHzB,OAAO,6BAA6B,eAItD,kBAAkB;CAcpB,MAAM,YAAYA,oDAZG,kBAChB,wBACA,QACkB,kBAClB,2BACA,uBACY,kBACb,gBACC,yBAQJ;CAED,gCAAa;EACX,MAAM,SAAS,OAAO;EACtB,UAAU,IAAI,OAAO;GACrB;CAEF,OAAO"}
@@ -1,76 +0,0 @@
1
- import { DebouncedSignal } from "./injectDebouncedSignal.cjs";
2
- import { Signal } from "@angular/core";
3
- import { DebouncerOptions, DebouncerState } from "@tanstack/pacer/debouncer";
4
-
5
- //#region src/debouncer/injectDebouncedValue.d.ts
6
- type Setter<T> = (value: T | ((prev: T) => T)) => void;
7
- /**
8
- * An Angular function that creates a debounced value that updates only after a specified delay.
9
- * Unlike injectDebouncedSignal, this function automatically tracks changes to the input signal
10
- * and updates the debounced value accordingly.
11
- *
12
- * The debounced value will only update after the specified wait time has elapsed since
13
- * the last change to the input value. If the input value changes again before the wait
14
- * time expires, the timer resets and starts waiting again.
15
- *
16
- * This is useful for deriving debounced values from signals that change frequently,
17
- * like search queries or form inputs, where you want to limit how often downstream effects
18
- * or calculations occur.
19
- *
20
- * The function returns a tuple containing:
21
- * - A Signal that provides the current debounced value
22
- * - The debouncer instance with control methods
23
- *
24
- * ## State Management and Selector
25
- *
26
- * The function uses TanStack Store for reactive state management via the underlying debouncer instance.
27
- * The `selector` parameter allows you to specify which debouncer state changes will trigger signal updates,
28
- * optimizing performance by preventing unnecessary subscriptions when irrelevant state changes occur.
29
- *
30
- * **By default, there will be no reactive state subscriptions** and you must opt-in to state
31
- * tracking by providing a selector function. This prevents unnecessary updates and gives you
32
- * full control over when your component tracks state changes. Only when you provide a selector will
33
- * the reactive system track the selected state values.
34
- *
35
- * Available debouncer state properties:
36
- * - `canLeadingExecute`: Whether the debouncer can execute on the leading edge
37
- * - `executionCount`: Number of function executions that have been completed
38
- * - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution
39
- * - `lastArgs`: The arguments from the most recent call to maybeExecute
40
- * - `status`: Current execution status ('disabled' | 'idle' | 'pending')
41
- *
42
- *
43
- * @example
44
- * ```ts
45
- * // Default behavior - no reactive state subscriptions
46
- * const searchQuery = signal('')
47
- * const debounced = injectDebouncedValue(searchQuery, {
48
- * wait: 500, // Wait 500ms after last change
49
- * })
50
- *
51
- * // Opt-in to reactive updates when pending state changes (optimized for loading indicators)
52
- * const debouncedWithPending = injectDebouncedValue(
53
- * searchQuery,
54
- * { wait: 500 },
55
- * (state) => ({ isPending: state.isPending }),
56
- * )
57
- *
58
- * // Debounced value will update 500ms after searchQuery stops changing
59
- * effect(() => {
60
- * fetchSearchResults(debounced())
61
- * })
62
- *
63
- * // Access selected debouncer state via signals (only if you provided a selector)
64
- * effect(() => {
65
- * console.log('Is pending:', debouncedWithPending.state().isPending)
66
- * })
67
- *
68
- * // Control the debouncer
69
- * debounced.cancel() // Cancel any pending updates
70
- * ```
71
- */
72
- declare function injectDebouncedValue<TValue, TSelected = {}>(value: Signal<TValue>, initialOptions: DebouncerOptions<Setter<TValue>>, selector?: (state: DebouncerState<Setter<TValue>>) => TSelected): DebouncedSignal<TValue, TSelected>;
73
- declare function injectDebouncedValue<TValue, TSelected = {}>(value: Signal<TValue>, initialValue: TValue, initialOptions: DebouncerOptions<Setter<TValue>>, selector?: (state: DebouncerState<Setter<TValue>>) => TSelected): DebouncedSignal<TValue, TSelected>;
74
- //#endregion
75
- export { injectDebouncedValue };
76
- //# sourceMappingURL=injectDebouncedValue.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectDebouncedValue.js","names":[],"sources":["../../src/debouncer/injectDebouncedValue.ts"],"sourcesContent":["import { effect } from '@angular/core'\nimport { injectDebouncedSignal } from './injectDebouncedSignal'\nimport type { DebouncedSignal } from './injectDebouncedSignal'\nimport type { Signal } from '@angular/core'\nimport type {\n DebouncerOptions,\n DebouncerState,\n} from '@tanstack/pacer/debouncer'\n\ntype Setter<T> = (value: T | ((prev: T) => T)) => void\n\n/**\n * An Angular function that creates a debounced value that updates only after a specified delay.\n * Unlike injectDebouncedSignal, this function automatically tracks changes to the input signal\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 signals 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 function returns a tuple containing:\n * - A Signal that provides the current debounced value\n * - The debouncer instance with control methods\n *\n * ## State Management and Selector\n *\n * The function 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 signal 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 updates and gives you\n * full control over when your component tracks 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 *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const searchQuery = signal('')\n * const debounced = injectDebouncedValue(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 debouncedWithPending = injectDebouncedValue(\n * searchQuery,\n * { wait: 500 },\n * (state) => ({ isPending: state.isPending }),\n * )\n *\n * // Debounced value will update 500ms after searchQuery stops changing\n * effect(() => {\n * fetchSearchResults(debounced())\n * })\n *\n * // Access selected debouncer state via signals (only if you provided a selector)\n * effect(() => {\n * console.log('Is pending:', debouncedWithPending.state().isPending)\n * })\n *\n * // Control the debouncer\n * debounced.cancel() // Cancel any pending updates\n * ```\n */\nexport function injectDebouncedValue<TValue, TSelected = {}>(\n value: Signal<TValue>,\n initialOptions: DebouncerOptions<Setter<TValue>>,\n selector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): DebouncedSignal<TValue, TSelected>\nexport function injectDebouncedValue<TValue, TSelected = {}>(\n value: Signal<TValue>,\n initialValue: TValue,\n initialOptions: DebouncerOptions<Setter<TValue>>,\n selector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): DebouncedSignal<TValue, TSelected>\nexport function injectDebouncedValue<TValue, TSelected = {}>(\n value: Signal<TValue>,\n initialValueOrOptions: TValue | DebouncerOptions<Setter<TValue>>,\n initialOptionsOrSelector?:\n | DebouncerOptions<Setter<TValue>>\n | ((state: DebouncerState<Setter<TValue>>) => TSelected),\n maybeSelector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): DebouncedSignal<TValue, TSelected> {\n const hasSelector = typeof initialOptionsOrSelector === 'function'\n\n const hasInitialValue =\n (initialOptionsOrSelector !== undefined && !hasSelector) ||\n maybeSelector !== undefined\n\n const initialValue = hasInitialValue\n ? (initialValueOrOptions as TValue)\n : (undefined as unknown as TValue)\n const initialOptions = hasInitialValue\n ? (initialOptionsOrSelector as DebouncerOptions<Setter<TValue>>)\n : (initialValueOrOptions as DebouncerOptions<Setter<TValue>>)\n const selector = hasInitialValue\n ? maybeSelector\n : (initialOptionsOrSelector as\n | ((state: DebouncerState<Setter<TValue>>) => TSelected)\n | undefined)\n\n const debounced = injectDebouncedSignal(\n initialValue,\n initialOptions,\n selector,\n )\n\n effect(() => {\n const latest = value()\n debounced.set(latest)\n })\n\n return debounced\n}\n"],"mappings":";;;;AAuFA,SAAgB,qBACd,OACA,uBACA,0BAGA,eACoC;CAGpC,MAAM,kBACH,6BAA6B,UAAa,EAHzB,OAAO,6BAA6B,eAItD,kBAAkB;CAcpB,MAAM,YAAY,sBAZG,kBAChB,wBACA,QACkB,kBAClB,2BACA,uBACY,kBACb,gBACC,yBAQJ;CAED,aAAa;EACX,MAAM,SAAS,OAAO;EACtB,UAAU,IAAI,OAAO;GACrB;CAEF,OAAO"}
@@ -1,95 +0,0 @@
1
- const require_pacer_context = require('../provider/pacer-context.cjs');
2
- let _angular_core = require("@angular/core");
3
- let _tanstack_angular_store = require("@tanstack/angular-store");
4
- let _tanstack_pacer_debouncer = require("@tanstack/pacer/debouncer");
5
-
6
- //#region src/debouncer/injectDebouncer.ts
7
- /**
8
- * An Angular function that creates and manages a Debouncer instance.
9
- *
10
- * This is a lower-level function that provides direct access to the Debouncer's functionality.
11
- * This allows you to integrate it with any state management solution you prefer.
12
- *
13
- * This function provides debouncing functionality to limit how often a function can be called,
14
- * waiting for a specified delay before executing the latest call. This is useful for handling
15
- * frequent events like window resizing, scroll events, or real-time search inputs.
16
- *
17
- * The debouncer will only execute the function after the specified wait time has elapsed
18
- * since the last call. If the function is called again before the wait time expires, the
19
- * timer resets and starts waiting again.
20
- *
21
- * ## State Management and Selector
22
- *
23
- * The function uses TanStack Store for state management and wraps it with Angular signals.
24
- * The `selector` parameter allows you to specify which state changes will trigger signal updates,
25
- * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.
26
- *
27
- * **By default, there will be no reactive state subscriptions** and you must opt-in to state
28
- * tracking by providing a selector function. This prevents unnecessary updates and gives you
29
- * full control over when your component tracks state changes.
30
- *
31
- * Available 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
- * ## Cleanup on Destroy
39
- *
40
- * By default, the function cancels any pending execution when the component is destroyed.
41
- * Use the `onUnmount` option to customize this. For example, to flush pending work instead:
42
- *
43
- * ```ts
44
- * const debouncer = injectDebouncer(fn, {
45
- * wait: 500,
46
- * onUnmount: (d) => d.flush()
47
- * });
48
- * ```
49
- *
50
- * @example
51
- * ```ts
52
- * // Default behavior - no reactive state subscriptions
53
- * const debouncer = injectDebouncer(
54
- * (query: string) => fetchSearchResults(query),
55
- * { wait: 500 }
56
- * );
57
- *
58
- * // Opt-in to track isPending changes (optimized for loading states)
59
- * const debouncer = injectDebouncer(
60
- * (query: string) => fetchSearchResults(query),
61
- * { wait: 500 },
62
- * (state) => ({ isPending: state.isPending })
63
- * );
64
- *
65
- * // In an event handler
66
- * const handleChange = (e: Event) => {
67
- * const target = e.target as HTMLInputElement
68
- * debouncer.maybeExecute(target.value);
69
- * };
70
- *
71
- * // Access the selected state (will be empty object {} unless selector provided)
72
- * const { isPending } = debouncer.state();
73
- * ```
74
- */
75
- function injectDebouncer(fn, options, selector = () => ({})) {
76
- const mergedOptions = {
77
- ...require_pacer_context.injectPacerOptions().debouncer,
78
- ...options
79
- };
80
- const debouncer = new _tanstack_pacer_debouncer.Debouncer(fn, mergedOptions);
81
- const state = (0, _tanstack_angular_store.injectSelector)(debouncer.store, selector);
82
- const result = {
83
- ...debouncer,
84
- state
85
- };
86
- (0, _angular_core.inject)(_angular_core.DestroyRef, { optional: true })?.onDestroy(() => {
87
- if (mergedOptions.onUnmount) mergedOptions.onUnmount(result);
88
- else debouncer.cancel();
89
- });
90
- return result;
91
- }
92
-
93
- //#endregion
94
- exports.injectDebouncer = injectDebouncer;
95
- //# sourceMappingURL=injectDebouncer.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectDebouncer.cjs","names":["injectPacerOptions","Debouncer","DestroyRef"],"sources":["../../src/debouncer/injectDebouncer.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { Debouncer } from '@tanstack/pacer/debouncer'\nimport { injectPacerOptions } from '../provider/pacer-context'\nimport type { Signal } from '@angular/core'\nimport type { Store } from '@tanstack/angular-store'\nimport type { AnyFunction } from '@tanstack/pacer/types'\nimport type {\n DebouncerOptions,\n DebouncerState,\n} from '@tanstack/pacer/debouncer'\n\nexport interface AngularDebouncerOptions<\n TFn extends AnyFunction,\n TSelected = {},\n> extends DebouncerOptions<TFn> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the debouncer instance.\n * When provided, replaces the default cleanup (cancel); use it to call flush(), cancel(), add logging, etc.\n */\n onUnmount?: (debouncer: AngularDebouncer<TFn, TSelected>) => void\n}\n\nexport interface AngularDebouncer<\n TFn extends AnyFunction,\n TSelected = {},\n> extends Omit<Debouncer<TFn>, 'store'> {\n /**\n * Reactive state signal that will be updated when the debouncer state changes\n *\n * Use this instead of `debouncer.store.state`\n */\n readonly state: Signal<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 in Angular signals.\n */\n readonly store: Store<Readonly<DebouncerState<TFn>>>\n}\n\n/**\n * An Angular function that creates and manages a Debouncer instance.\n *\n * This is a lower-level function that provides direct access to the Debouncer's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * This function 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 function uses TanStack Store for state management and wraps it with Angular signals.\n * The `selector` parameter allows you to specify which state changes will trigger signal updates,\n * optimizing performance by preventing unnecessary updates 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 updates and gives you\n * full control over when your component tracks state changes.\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 * ## Cleanup on Destroy\n *\n * By default, the function cancels any pending execution when the component is destroyed.\n * Use the `onUnmount` option to customize this. For example, to flush pending work instead:\n *\n * ```ts\n * const debouncer = injectDebouncer(fn, {\n * wait: 500,\n * onUnmount: (d) => d.flush()\n * });\n * ```\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const debouncer = injectDebouncer(\n * (query: string) => fetchSearchResults(query),\n * { wait: 500 }\n * );\n *\n * // Opt-in to track isPending changes (optimized for loading states)\n * const debouncer = injectDebouncer(\n * (query: string) => fetchSearchResults(query),\n * { wait: 500 },\n * (state) => ({ isPending: state.isPending })\n * );\n *\n * // In an event handler\n * const handleChange = (e: Event) => {\n * const target = e.target as HTMLInputElement\n * debouncer.maybeExecute(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 injectDebouncer<TFn extends AnyFunction, TSelected = {}>(\n fn: TFn,\n options: AngularDebouncerOptions<TFn, TSelected>,\n selector: (state: DebouncerState<TFn>) => TSelected = () => ({}) as TSelected,\n): AngularDebouncer<TFn, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().debouncer,\n ...options,\n } as AngularDebouncerOptions<TFn, TSelected>\n\n const debouncer = new Debouncer<TFn>(fn, mergedOptions)\n const state = injectSelector(debouncer.store, selector)\n\n const result = {\n ...debouncer,\n state,\n } as AngularDebouncer<TFn, TSelected>\n\n const destroyRef = inject(DestroyRef, { optional: true })\n destroyRef?.onDestroy(() => {\n if (mergedOptions.onUnmount) {\n mergedOptions.onUnmount(result)\n } else {\n debouncer.cancel()\n }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4GA,SAAgB,gBACd,IACA,SACA,kBAA6D,EAAE,GAC7B;CAClC,MAAM,gBAAgB;EACpB,GAAGA,0CAAoB,CAAC;EACxB,GAAG;EACJ;CAED,MAAM,YAAY,IAAIC,oCAAe,IAAI,cAAc;CACvD,MAAM,oDAAuB,UAAU,OAAO,SAAS;CAEvD,MAAM,SAAS;EACb,GAAG;EACH;EACD;CAGD,0BAD0BC,0BAAY,EAAE,UAAU,MAAM,CAC9C,EAAE,gBAAgB;EAC1B,IAAI,cAAc,WAChB,cAAc,UAAU,OAAO;OAE/B,UAAU,QAAQ;GAEpB;CAEF,OAAO"}
@@ -1,98 +0,0 @@
1
- import { Signal } from "@angular/core";
2
- import { Store } from "@tanstack/angular-store";
3
- import { AnyFunction } from "@tanstack/pacer/types";
4
- import { Debouncer, DebouncerOptions, DebouncerState } from "@tanstack/pacer/debouncer";
5
-
6
- //#region src/debouncer/injectDebouncer.d.ts
7
- interface AngularDebouncerOptions<TFn extends AnyFunction, TSelected = {}> extends DebouncerOptions<TFn> {
8
- /**
9
- * Optional callback invoked when the component is destroyed. Receives the debouncer instance.
10
- * When provided, replaces the default cleanup (cancel); use it to call flush(), cancel(), add logging, etc.
11
- */
12
- onUnmount?: (debouncer: AngularDebouncer<TFn, TSelected>) => void;
13
- }
14
- interface AngularDebouncer<TFn extends AnyFunction, TSelected = {}> extends Omit<Debouncer<TFn>, 'store'> {
15
- /**
16
- * Reactive state signal that will be updated when the debouncer state changes
17
- *
18
- * Use this instead of `debouncer.store.state`
19
- */
20
- readonly state: Signal<Readonly<TSelected>>;
21
- /**
22
- * @deprecated Use `debouncer.state` instead of `debouncer.store.state` if you want to read reactive state.
23
- * The state on the store object is not reactive in Angular signals.
24
- */
25
- readonly store: Store<Readonly<DebouncerState<TFn>>>;
26
- }
27
- /**
28
- * An Angular function that creates and manages a Debouncer instance.
29
- *
30
- * This is a lower-level function that provides direct access to the Debouncer's functionality.
31
- * This allows you to integrate it with any state management solution you prefer.
32
- *
33
- * This function provides debouncing functionality to limit how often a function can be called,
34
- * waiting for a specified delay before executing the latest call. This is useful for handling
35
- * frequent events like window resizing, scroll events, or real-time search inputs.
36
- *
37
- * The debouncer will only execute the function after the specified wait time has elapsed
38
- * since the last call. If the function is called again before the wait time expires, the
39
- * timer resets and starts waiting again.
40
- *
41
- * ## State Management and Selector
42
- *
43
- * The function uses TanStack Store for state management and wraps it with Angular signals.
44
- * The `selector` parameter allows you to specify which state changes will trigger signal updates,
45
- * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.
46
- *
47
- * **By default, there will be no reactive state subscriptions** and you must opt-in to state
48
- * tracking by providing a selector function. This prevents unnecessary updates and gives you
49
- * full control over when your component tracks state changes.
50
- *
51
- * Available state properties:
52
- * - `canLeadingExecute`: Whether the debouncer can execute on the leading edge
53
- * - `executionCount`: Number of function executions that have been completed
54
- * - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution
55
- * - `lastArgs`: The arguments from the most recent call to maybeExecute
56
- * - `status`: Current execution status ('disabled' | 'idle' | 'pending')
57
- *
58
- * ## Cleanup on Destroy
59
- *
60
- * By default, the function cancels any pending execution when the component is destroyed.
61
- * Use the `onUnmount` option to customize this. For example, to flush pending work instead:
62
- *
63
- * ```ts
64
- * const debouncer = injectDebouncer(fn, {
65
- * wait: 500,
66
- * onUnmount: (d) => d.flush()
67
- * });
68
- * ```
69
- *
70
- * @example
71
- * ```ts
72
- * // Default behavior - no reactive state subscriptions
73
- * const debouncer = injectDebouncer(
74
- * (query: string) => fetchSearchResults(query),
75
- * { wait: 500 }
76
- * );
77
- *
78
- * // Opt-in to track isPending changes (optimized for loading states)
79
- * const debouncer = injectDebouncer(
80
- * (query: string) => fetchSearchResults(query),
81
- * { wait: 500 },
82
- * (state) => ({ isPending: state.isPending })
83
- * );
84
- *
85
- * // In an event handler
86
- * const handleChange = (e: Event) => {
87
- * const target = e.target as HTMLInputElement
88
- * debouncer.maybeExecute(target.value);
89
- * };
90
- *
91
- * // Access the selected state (will be empty object {} unless selector provided)
92
- * const { isPending } = debouncer.state();
93
- * ```
94
- */
95
- declare function injectDebouncer<TFn extends AnyFunction, TSelected = {}>(fn: TFn, options: AngularDebouncerOptions<TFn, TSelected>, selector?: (state: DebouncerState<TFn>) => TSelected): AngularDebouncer<TFn, TSelected>;
96
- //#endregion
97
- export { AngularDebouncer, AngularDebouncerOptions, injectDebouncer };
98
- //# sourceMappingURL=injectDebouncer.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectDebouncer.js","names":[],"sources":["../../src/debouncer/injectDebouncer.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { Debouncer } from '@tanstack/pacer/debouncer'\nimport { injectPacerOptions } from '../provider/pacer-context'\nimport type { Signal } from '@angular/core'\nimport type { Store } from '@tanstack/angular-store'\nimport type { AnyFunction } from '@tanstack/pacer/types'\nimport type {\n DebouncerOptions,\n DebouncerState,\n} from '@tanstack/pacer/debouncer'\n\nexport interface AngularDebouncerOptions<\n TFn extends AnyFunction,\n TSelected = {},\n> extends DebouncerOptions<TFn> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the debouncer instance.\n * When provided, replaces the default cleanup (cancel); use it to call flush(), cancel(), add logging, etc.\n */\n onUnmount?: (debouncer: AngularDebouncer<TFn, TSelected>) => void\n}\n\nexport interface AngularDebouncer<\n TFn extends AnyFunction,\n TSelected = {},\n> extends Omit<Debouncer<TFn>, 'store'> {\n /**\n * Reactive state signal that will be updated when the debouncer state changes\n *\n * Use this instead of `debouncer.store.state`\n */\n readonly state: Signal<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 in Angular signals.\n */\n readonly store: Store<Readonly<DebouncerState<TFn>>>\n}\n\n/**\n * An Angular function that creates and manages a Debouncer instance.\n *\n * This is a lower-level function that provides direct access to the Debouncer's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * This function 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 function uses TanStack Store for state management and wraps it with Angular signals.\n * The `selector` parameter allows you to specify which state changes will trigger signal updates,\n * optimizing performance by preventing unnecessary updates 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 updates and gives you\n * full control over when your component tracks state changes.\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 * ## Cleanup on Destroy\n *\n * By default, the function cancels any pending execution when the component is destroyed.\n * Use the `onUnmount` option to customize this. For example, to flush pending work instead:\n *\n * ```ts\n * const debouncer = injectDebouncer(fn, {\n * wait: 500,\n * onUnmount: (d) => d.flush()\n * });\n * ```\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const debouncer = injectDebouncer(\n * (query: string) => fetchSearchResults(query),\n * { wait: 500 }\n * );\n *\n * // Opt-in to track isPending changes (optimized for loading states)\n * const debouncer = injectDebouncer(\n * (query: string) => fetchSearchResults(query),\n * { wait: 500 },\n * (state) => ({ isPending: state.isPending })\n * );\n *\n * // In an event handler\n * const handleChange = (e: Event) => {\n * const target = e.target as HTMLInputElement\n * debouncer.maybeExecute(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 injectDebouncer<TFn extends AnyFunction, TSelected = {}>(\n fn: TFn,\n options: AngularDebouncerOptions<TFn, TSelected>,\n selector: (state: DebouncerState<TFn>) => TSelected = () => ({}) as TSelected,\n): AngularDebouncer<TFn, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().debouncer,\n ...options,\n } as AngularDebouncerOptions<TFn, TSelected>\n\n const debouncer = new Debouncer<TFn>(fn, mergedOptions)\n const state = injectSelector(debouncer.store, selector)\n\n const result = {\n ...debouncer,\n state,\n } as AngularDebouncer<TFn, TSelected>\n\n const destroyRef = inject(DestroyRef, { optional: true })\n destroyRef?.onDestroy(() => {\n if (mergedOptions.onUnmount) {\n mergedOptions.onUnmount(result)\n } else {\n debouncer.cancel()\n }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4GA,SAAgB,gBACd,IACA,SACA,kBAA6D,EAAE,GAC7B;CAClC,MAAM,gBAAgB;EACpB,GAAG,oBAAoB,CAAC;EACxB,GAAG;EACJ;CAED,MAAM,YAAY,IAAI,UAAe,IAAI,cAAc;CACvD,MAAM,QAAQ,eAAe,UAAU,OAAO,SAAS;CAEvD,MAAM,SAAS;EACb,GAAG;EACH;EACD;CAGD,AADmB,OAAO,YAAY,EAAE,UAAU,MAAM,CAC9C,EAAE,gBAAgB;EAC1B,IAAI,cAAc,WAChB,cAAc,UAAU,OAAO;OAE/B,UAAU,QAAQ;GAEpB;CAEF,OAAO"}