@tanstack/angular-pacer 0.24.0 → 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 +4 -4
  2. package/dist/async-batcher/injectAsyncBatchedCallback.d.ts +2 -4
  3. package/dist/async-batcher/injectAsyncBatchedCallback.js +1 -2
  4. package/dist/async-batcher/injectAsyncBatcher.d.ts +4 -6
  5. package/dist/async-batcher/injectAsyncBatcher.js +1 -2
  6. package/dist/async-debouncer/injectAsyncDebouncedCallback.d.ts +2 -4
  7. package/dist/async-debouncer/injectAsyncDebouncedCallback.js +1 -2
  8. package/dist/async-debouncer/injectAsyncDebouncer.d.ts +4 -6
  9. package/dist/async-debouncer/injectAsyncDebouncer.js +1 -2
  10. package/dist/async-queuer/injectAsyncQueuedSignal.d.ts +3 -5
  11. package/dist/async-queuer/injectAsyncQueuedSignal.js +1 -2
  12. package/dist/async-queuer/injectAsyncQueuer.d.ts +4 -6
  13. package/dist/async-queuer/injectAsyncQueuer.js +1 -2
  14. package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.d.ts +2 -4
  15. package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.js +1 -2
  16. package/dist/async-rate-limiter/injectAsyncRateLimiter.d.ts +4 -6
  17. package/dist/async-rate-limiter/injectAsyncRateLimiter.js +1 -2
  18. package/dist/async-throttler/injectAsyncThrottledCallback.d.ts +2 -4
  19. package/dist/async-throttler/injectAsyncThrottledCallback.js +1 -2
  20. package/dist/async-throttler/injectAsyncThrottler.d.ts +4 -6
  21. package/dist/async-throttler/injectAsyncThrottler.js +1 -2
  22. package/dist/batcher/injectBatchedCallback.d.ts +2 -4
  23. package/dist/batcher/injectBatchedCallback.js +1 -2
  24. package/dist/batcher/injectBatcher.d.ts +4 -6
  25. package/dist/batcher/injectBatcher.js +1 -2
  26. package/dist/debouncer/injectDebouncedCallback.d.ts +2 -4
  27. package/dist/debouncer/injectDebouncedCallback.js +1 -2
  28. package/dist/debouncer/injectDebouncedSignal.d.ts +3 -5
  29. package/dist/debouncer/injectDebouncedSignal.js +1 -2
  30. package/dist/debouncer/injectDebouncedValue.d.ts +3 -5
  31. package/dist/debouncer/injectDebouncedValue.js +1 -2
  32. package/dist/debouncer/injectDebouncer.d.ts +4 -6
  33. package/dist/debouncer/injectDebouncer.js +1 -2
  34. package/dist/provider/pacer-context.d.ts +4 -6
  35. package/dist/provider/pacer-context.js +1 -2
  36. package/dist/provider/pacer-provider.d.ts +2 -4
  37. package/dist/provider/pacer-provider.js +1 -2
  38. package/dist/queuer/injectQueuedSignal.d.ts +3 -5
  39. package/dist/queuer/injectQueuedSignal.js +1 -2
  40. package/dist/queuer/injectQueuedValue.d.ts +3 -5
  41. package/dist/queuer/injectQueuedValue.js +1 -2
  42. package/dist/queuer/injectQueuer.d.ts +4 -6
  43. package/dist/queuer/injectQueuer.js +1 -2
  44. package/dist/rate-limiter/injectRateLimitedCallback.d.ts +2 -4
  45. package/dist/rate-limiter/injectRateLimitedCallback.js +1 -2
  46. package/dist/rate-limiter/injectRateLimitedSignal.d.ts +3 -5
  47. package/dist/rate-limiter/injectRateLimitedSignal.js +1 -2
  48. package/dist/rate-limiter/injectRateLimitedValue.d.ts +3 -5
  49. package/dist/rate-limiter/injectRateLimitedValue.js +1 -2
  50. package/dist/rate-limiter/injectRateLimiter.d.ts +4 -6
  51. package/dist/rate-limiter/injectRateLimiter.js +1 -2
  52. package/dist/throttler/injectThrottledCallback.d.ts +2 -4
  53. package/dist/throttler/injectThrottledCallback.js +1 -2
  54. package/dist/throttler/injectThrottledSignal.d.ts +3 -7
  55. package/dist/throttler/injectThrottledSignal.js +1 -4
  56. package/dist/throttler/injectThrottledValue.d.ts +3 -7
  57. package/dist/throttler/injectThrottledValue.js +1 -2
  58. package/dist/throttler/injectThrottler.d.ts +4 -8
  59. package/dist/throttler/injectThrottler.js +1 -4
  60. package/package.json +24 -71
  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 -44
  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 -84
  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 -42
  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 -107
  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 -49
  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 -84
  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 -45
  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 -71
  100. package/dist/async-rate-limiter/injectAsyncRateLimiter.js.map +0 -1
  101. package/dist/async-retryer/index.cjs +0 -8
  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 -43
  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 -86
  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 -42
  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 -76
  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 -42
  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 -59
  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 -75
  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 -97
  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 -20
  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 -35
  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 -43
  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 -33
  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 -81
  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 -41
  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 -53
  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 -48
  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 -102
  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 -41
  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 -60
  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 -73
  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 -97
  202. package/dist/throttler/injectThrottler.js.map +0 -1
  203. package/dist/types/index.cjs +0 -8
  204. package/dist/types/index.d.cts +0 -1
  205. package/dist/utils/index.cjs +0 -8
  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 -125
  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 -99
  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 -98
  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 -123
  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,84 +0,0 @@
1
- import { AsyncBatcher, AsyncBatcherOptions, AsyncBatcherState } from "@tanstack/pacer/async-batcher";
2
- import { Signal } from "@angular/core";
3
- import { Store } from "@tanstack/angular-store";
4
- //#region src/async-batcher/injectAsyncBatcher.d.ts
5
- interface AngularAsyncBatcherOptions<TValue, TSelected = {}> extends AsyncBatcherOptions<TValue> {
6
- /**
7
- * Optional callback invoked when the component is destroyed. Receives the batcher instance.
8
- * When provided, replaces the default cleanup (cancel + abort); use it to call flush(), cancel(), add logging, etc.
9
- * When using onUnmount with flush, guard your callbacks since the component may already be destroyed.
10
- */
11
- onUnmount?: (batcher: AngularAsyncBatcher<TValue, TSelected>) => void;
12
- }
13
- interface AngularAsyncBatcher<TValue, TSelected = {}> extends Omit<AsyncBatcher<TValue>, 'store'> {
14
- /**
15
- * Reactive state signal that will be updated when the async batcher state changes
16
- *
17
- * Use this instead of `batcher.store.state`
18
- */
19
- readonly state: Signal<Readonly<TSelected>>;
20
- /**
21
- * @deprecated Use `batcher.state` instead of `batcher.store.state` if you want to read reactive state.
22
- * The state on the store object is not reactive in Angular signals.
23
- */
24
- readonly store: Store<Readonly<AsyncBatcherState<TValue>>>;
25
- }
26
- /**
27
- * An Angular function that creates and manages an AsyncBatcher instance.
28
- *
29
- * This is a lower-level function that provides direct access to the AsyncBatcher's functionality.
30
- * This allows you to integrate it with any state management solution you prefer.
31
- *
32
- * The AsyncBatcher collects items and processes them in batches asynchronously with support for
33
- * promise-based processing, error handling, retry capabilities, and abort support.
34
- *
35
- * ## State Management and Selector
36
- *
37
- * The function uses TanStack Store for state management and wraps it with Angular signals.
38
- * The `selector` parameter allows you to specify which state changes will trigger signal updates,
39
- * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.
40
- *
41
- * **By default, there will be no reactive state subscriptions** and you must opt-in to state
42
- * tracking by providing a selector function. This prevents unnecessary updates and gives you
43
- * full control over when your component tracks state changes.
44
- *
45
- * ## Cleanup on Destroy
46
- *
47
- * By default, the function cancels any pending batch and aborts in-flight work when the component is destroyed.
48
- * Use the `onUnmount` option to customize this. For example, to flush pending work instead:
49
- *
50
- * ```ts
51
- * const batcher = injectAsyncBatcher(fn, {
52
- * maxSize: 10,
53
- * onUnmount: (b) => b.flush()
54
- * });
55
- * ```
56
- *
57
- * When using onUnmount with flush, guard your callbacks since the component may already be destroyed.
58
- *
59
- * @example
60
- * ```ts
61
- * // Default behavior - no reactive state subscriptions
62
- * const batcher = injectAsyncBatcher(
63
- * async (items: Array<Data>) => {
64
- * const response = await fetch('/api/batch', {
65
- * method: 'POST',
66
- * body: JSON.stringify(items)
67
- * });
68
- * return response.json();
69
- * },
70
- * { maxSize: 10, wait: 2000 }
71
- * );
72
- *
73
- * // Add items
74
- * batcher.addItem(data1);
75
- * batcher.addItem(data2);
76
- *
77
- * // Access the selected state
78
- * const { items, isExecuting } = batcher.state();
79
- * ```
80
- */
81
- declare function injectAsyncBatcher<TValue, TSelected = {}>(fn: (items: Array<TValue>) => Promise<any>, options?: AngularAsyncBatcherOptions<TValue, TSelected>, selector?: (state: AsyncBatcherState<TValue>) => TSelected): AngularAsyncBatcher<TValue, TSelected>;
82
- //#endregion
83
- export { AngularAsyncBatcher, AngularAsyncBatcherOptions, injectAsyncBatcher };
84
- //# sourceMappingURL=injectAsyncBatcher.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectAsyncBatcher.js","names":[],"sources":["../../src/async-batcher/injectAsyncBatcher.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { AsyncBatcher } from '@tanstack/pacer/async-batcher'\nimport { injectPacerOptions } from '../provider/pacer-context'\nimport type { Signal } from '@angular/core'\nimport type { Store } from '@tanstack/angular-store'\nimport type {\n AsyncBatcherOptions,\n AsyncBatcherState,\n} from '@tanstack/pacer/async-batcher'\n\nexport interface AngularAsyncBatcherOptions<\n TValue,\n TSelected = {},\n> extends AsyncBatcherOptions<TValue> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the batcher instance.\n * When provided, replaces the default cleanup (cancel + abort); use it to call flush(), cancel(), add logging, etc.\n * When using onUnmount with flush, guard your callbacks since the component may already be destroyed.\n */\n onUnmount?: (batcher: AngularAsyncBatcher<TValue, TSelected>) => void\n}\n\nexport interface AngularAsyncBatcher<TValue, TSelected = {}> extends Omit<\n AsyncBatcher<TValue>,\n 'store'\n> {\n /**\n * Reactive state signal that will be updated when the async batcher state changes\n *\n * Use this instead of `batcher.store.state`\n */\n readonly state: Signal<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 in Angular signals.\n */\n readonly store: Store<Readonly<AsyncBatcherState<TValue>>>\n}\n\n/**\n * An Angular function that creates and manages an AsyncBatcher instance.\n *\n * This is a lower-level function that provides direct access to the AsyncBatcher's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * The AsyncBatcher collects items and processes them in batches asynchronously with support for\n * promise-based processing, error handling, retry capabilities, and abort support.\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 * ## Cleanup on Destroy\n *\n * By default, the function cancels any pending batch and aborts in-flight work 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 batcher = injectAsyncBatcher(fn, {\n * maxSize: 10,\n * onUnmount: (b) => b.flush()\n * });\n * ```\n *\n * When using onUnmount with flush, guard your callbacks since the component may already be destroyed.\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const batcher = injectAsyncBatcher(\n * async (items: Array<Data>) => {\n * const response = await fetch('/api/batch', {\n * method: 'POST',\n * body: JSON.stringify(items)\n * });\n * return response.json();\n * },\n * { maxSize: 10, wait: 2000 }\n * );\n *\n * // Add items\n * batcher.addItem(data1);\n * batcher.addItem(data2);\n *\n * // Access the selected state\n * const { items, isExecuting } = batcher.state();\n * ```\n */\nexport function injectAsyncBatcher<TValue, TSelected = {}>(\n fn: (items: Array<TValue>) => Promise<any>,\n options: AngularAsyncBatcherOptions<TValue, TSelected> = {},\n selector: (state: AsyncBatcherState<TValue>) => TSelected = () =>\n ({}) as TSelected,\n): AngularAsyncBatcher<TValue, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().asyncBatcher,\n ...options,\n } as AngularAsyncBatcherOptions<TValue, TSelected>\n\n const batcher = new AsyncBatcher<TValue>(fn, mergedOptions)\n const state = injectSelector(batcher.store, selector)\n\n const result = {\n ...batcher,\n state,\n } as AngularAsyncBatcher<TValue, TSelected>\n\n const destroyRef = inject(DestroyRef, { optional: true })\n destroyRef?.onDestroy(() => {\n if (mergedOptions.onUnmount) {\n mergedOptions.onUnmount(result)\n } else {\n batcher.cancel()\n batcher.abort()\n }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+FA,SAAgB,mBACd,IACA,UAAyD,CAAC,GAC1D,kBACG,CAAC,IACoC;CACxC,MAAM,gBAAgB;EACpB,GAAG,mBAAmB,CAAC,CAAC;EACxB,GAAG;CACL;CAEA,MAAM,UAAU,IAAI,aAAqB,IAAI,aAAa;CAC1D,MAAM,QAAQ,eAAe,QAAQ,OAAO,QAAQ;CAEpD,MAAM,SAAS;EACb,GAAG;EACH;CACF;CAGA,AADmB,OAAO,YAAY,EAAE,UAAU,KAAK,CAC9C,CAAC,EAAE,gBAAgB;EAC1B,IAAI,cAAc,WAChB,cAAc,UAAU,MAAM;OACzB;GACL,QAAQ,OAAO;GACf,QAAQ,MAAM;EAChB;CACF,CAAC;CAED,OAAO;AACT"}
@@ -1,13 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_injectAsyncDebouncer = require('./injectAsyncDebouncer.cjs');
3
- const require_injectAsyncDebouncedCallback = require('./injectAsyncDebouncedCallback.cjs');
4
-
5
- exports.injectAsyncDebouncedCallback = require_injectAsyncDebouncedCallback.injectAsyncDebouncedCallback;
6
- exports.injectAsyncDebouncer = require_injectAsyncDebouncer.injectAsyncDebouncer;
7
- var _tanstack_pacer_async_debouncer = require("@tanstack/pacer/async-debouncer");
8
- Object.keys(_tanstack_pacer_async_debouncer).forEach(function (k) {
9
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
10
- enumerable: true,
11
- get: function () { return _tanstack_pacer_async_debouncer[k]; }
12
- });
13
- });
@@ -1,4 +0,0 @@
1
- import { injectAsyncDebouncedCallback } from "./injectAsyncDebouncedCallback.cjs";
2
- import { AngularAsyncDebouncer, AngularAsyncDebouncerOptions, injectAsyncDebouncer } from "./injectAsyncDebouncer.cjs";
3
- export * from "@tanstack/pacer/async-debouncer";
4
- export { AngularAsyncDebouncer, AngularAsyncDebouncerOptions, injectAsyncDebouncedCallback, injectAsyncDebouncer };
@@ -1,49 +0,0 @@
1
- const require_injectAsyncDebouncer = require('./injectAsyncDebouncer.cjs');
2
-
3
- //#region src/async-debouncer/injectAsyncDebouncedCallback.ts
4
- /**
5
- * An Angular function that creates an async debounced version of a callback function.
6
- * This function is essentially a wrapper around `injectAsyncDebouncer` that provides
7
- * a simplified API for basic async 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 `injectAsyncDebouncer`, making it ideal for basic
14
- * async debouncing needs. However, it does not expose the underlying AsyncDebouncer instance.
15
- *
16
- * For advanced usage requiring features like:
17
- * - Manual cancellation
18
- * - Access to execution counts
19
- * - Error handling callbacks
20
- * - Retry support
21
- *
22
- * Consider using the `injectAsyncDebouncer` function instead.
23
- *
24
- * @example
25
- * ```ts
26
- * // Debounce an async search handler
27
- * const handleSearch = injectAsyncDebouncedCallback(
28
- * async (query: string) => {
29
- * const response = await fetch(`/api/search?q=${query}`);
30
- * return response.json();
31
- * },
32
- * { wait: 500 }
33
- * );
34
- *
35
- * // Use in an input
36
- * const results = await handleSearch(searchQuery);
37
- * ```
38
- */
39
- function injectAsyncDebouncedCallback(fn, options) {
40
- const debouncer = require_injectAsyncDebouncer.injectAsyncDebouncer(fn, options);
41
- return async (...args) => {
42
- const result = await debouncer.maybeExecute(...args);
43
- return result !== void 0 ? await result : void 0;
44
- };
45
- }
46
-
47
- //#endregion
48
- exports.injectAsyncDebouncedCallback = injectAsyncDebouncedCallback;
49
- //# sourceMappingURL=injectAsyncDebouncedCallback.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectAsyncDebouncedCallback.cjs","names":["injectAsyncDebouncer"],"sources":["../../src/async-debouncer/injectAsyncDebouncedCallback.ts"],"sourcesContent":["import { injectAsyncDebouncer } from './injectAsyncDebouncer'\nimport type { AsyncDebouncerOptions } from '@tanstack/pacer/async-debouncer'\nimport type { AnyAsyncFunction } from '@tanstack/pacer/types'\n\n/**\n * An Angular function that creates an async debounced version of a callback function.\n * This function is essentially a wrapper around `injectAsyncDebouncer` that provides\n * a simplified API for basic async 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 `injectAsyncDebouncer`, making it ideal for basic\n * async debouncing needs. However, it does not expose the underlying AsyncDebouncer instance.\n *\n * For advanced usage requiring features like:\n * - Manual cancellation\n * - Access to execution counts\n * - Error handling callbacks\n * - Retry support\n *\n * Consider using the `injectAsyncDebouncer` function instead.\n *\n * @example\n * ```ts\n * // Debounce an async search handler\n * const handleSearch = injectAsyncDebouncedCallback(\n * async (query: string) => {\n * const response = await fetch(`/api/search?q=${query}`);\n * return response.json();\n * },\n * { wait: 500 }\n * );\n *\n * // Use in an input\n * const results = await handleSearch(searchQuery);\n * ```\n */\nexport function injectAsyncDebouncedCallback<TFn extends AnyAsyncFunction>(\n fn: TFn,\n options: AsyncDebouncerOptions<TFn>,\n): (...args: Parameters<TFn>) => Promise<Awaited<ReturnType<TFn>> | undefined> {\n const debouncer = injectAsyncDebouncer(fn, options)\n return async (...args: Parameters<TFn>) => {\n const result = await debouncer.maybeExecute(...args)\n // Not sure if this is the best way to handle this,\n return result !== undefined ? await result : undefined\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,6BACd,IACA,SAC6E;CAC7E,MAAM,YAAYA,kDAAqB,IAAI,OAAO;CAClD,OAAO,OAAO,GAAG,SAA0B;EACzC,MAAM,SAAS,MAAM,UAAU,aAAa,GAAG,IAAI;EAEnD,OAAO,WAAW,SAAY,MAAM,SAAS;CAC/C;AACF"}
@@ -1,42 +0,0 @@
1
- import { AsyncDebouncerOptions } from "@tanstack/pacer/async-debouncer";
2
- import { AnyAsyncFunction } from "@tanstack/pacer/types";
3
- //#region src/async-debouncer/injectAsyncDebouncedCallback.d.ts
4
- /**
5
- * An Angular function that creates an async debounced version of a callback function.
6
- * This function is essentially a wrapper around `injectAsyncDebouncer` that provides
7
- * a simplified API for basic async 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 `injectAsyncDebouncer`, making it ideal for basic
14
- * async debouncing needs. However, it does not expose the underlying AsyncDebouncer instance.
15
- *
16
- * For advanced usage requiring features like:
17
- * - Manual cancellation
18
- * - Access to execution counts
19
- * - Error handling callbacks
20
- * - Retry support
21
- *
22
- * Consider using the `injectAsyncDebouncer` function instead.
23
- *
24
- * @example
25
- * ```ts
26
- * // Debounce an async search handler
27
- * const handleSearch = injectAsyncDebouncedCallback(
28
- * async (query: string) => {
29
- * const response = await fetch(`/api/search?q=${query}`);
30
- * return response.json();
31
- * },
32
- * { wait: 500 }
33
- * );
34
- *
35
- * // Use in an input
36
- * const results = await handleSearch(searchQuery);
37
- * ```
38
- */
39
- declare function injectAsyncDebouncedCallback<TFn extends AnyAsyncFunction>(fn: TFn, options: AsyncDebouncerOptions<TFn>): (...args: Parameters<TFn>) => Promise<Awaited<ReturnType<TFn>> | undefined>;
40
- //#endregion
41
- export { injectAsyncDebouncedCallback };
42
- //# sourceMappingURL=injectAsyncDebouncedCallback.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectAsyncDebouncedCallback.js","names":[],"sources":["../../src/async-debouncer/injectAsyncDebouncedCallback.ts"],"sourcesContent":["import { injectAsyncDebouncer } from './injectAsyncDebouncer'\nimport type { AsyncDebouncerOptions } from '@tanstack/pacer/async-debouncer'\nimport type { AnyAsyncFunction } from '@tanstack/pacer/types'\n\n/**\n * An Angular function that creates an async debounced version of a callback function.\n * This function is essentially a wrapper around `injectAsyncDebouncer` that provides\n * a simplified API for basic async 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 `injectAsyncDebouncer`, making it ideal for basic\n * async debouncing needs. However, it does not expose the underlying AsyncDebouncer instance.\n *\n * For advanced usage requiring features like:\n * - Manual cancellation\n * - Access to execution counts\n * - Error handling callbacks\n * - Retry support\n *\n * Consider using the `injectAsyncDebouncer` function instead.\n *\n * @example\n * ```ts\n * // Debounce an async search handler\n * const handleSearch = injectAsyncDebouncedCallback(\n * async (query: string) => {\n * const response = await fetch(`/api/search?q=${query}`);\n * return response.json();\n * },\n * { wait: 500 }\n * );\n *\n * // Use in an input\n * const results = await handleSearch(searchQuery);\n * ```\n */\nexport function injectAsyncDebouncedCallback<TFn extends AnyAsyncFunction>(\n fn: TFn,\n options: AsyncDebouncerOptions<TFn>,\n): (...args: Parameters<TFn>) => Promise<Awaited<ReturnType<TFn>> | undefined> {\n const debouncer = injectAsyncDebouncer(fn, options)\n return async (...args: Parameters<TFn>) => {\n const result = await debouncer.maybeExecute(...args)\n // Not sure if this is the best way to handle this,\n return result !== undefined ? await result : undefined\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,6BACd,IACA,SAC6E;CAC7E,MAAM,YAAY,qBAAqB,IAAI,OAAO;CAClD,OAAO,OAAO,GAAG,SAA0B;EACzC,MAAM,SAAS,MAAM,UAAU,aAAa,GAAG,IAAI;EAEnD,OAAO,WAAW,SAAY,MAAM,SAAS;CAC/C;AACF"}
@@ -1,107 +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_async_debouncer = require("@tanstack/pacer/async-debouncer");
5
-
6
- //#region src/async-debouncer/injectAsyncDebouncer.ts
7
- /**
8
- * An Angular function that creates and manages an AsyncDebouncer instance.
9
- *
10
- * This is a lower-level function that provides direct access to the AsyncDebouncer's functionality.
11
- * This allows you to integrate it with any state management solution you prefer.
12
- *
13
- * This function provides async debouncing functionality with promise support, error handling,
14
- * retry capabilities, and abort support.
15
- *
16
- * The debouncer will only execute the function after the specified wait time has elapsed
17
- * since the last call. If the function is called again before the wait time expires, the
18
- * timer resets and starts waiting again.
19
- *
20
- * ## State Management and Selector
21
- *
22
- * The function uses TanStack Store for state management and wraps it with Angular signals.
23
- * The `selector` parameter allows you to specify which state changes will trigger signal updates,
24
- * optimizing performance by preventing unnecessary updates 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 updates and gives you
28
- * full control over when your component tracks state changes.
29
- *
30
- * Available state properties:
31
- * - `canLeadingExecute`: Whether the debouncer can execute on the leading edge
32
- * - `errorCount`: Number of function executions that have resulted in errors
33
- * - `isExecuting`: Whether the debounced function is currently executing asynchronously
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
- * - `lastResult`: The result from the most recent successful function execution
37
- * - `settleCount`: Number of function executions that have completed (either successfully or with errors)
38
- * - `status`: Current execution status ('disabled' | 'idle' | 'pending' | 'executing' | 'settled')
39
- * - `successCount`: Number of function executions that have completed successfully
40
- *
41
- * ## Cleanup on Destroy
42
- *
43
- * By default, the function cancels any pending execution and aborts in-flight work when the component is destroyed.
44
- * Use the `onUnmount` option to customize this. For example, to flush pending work instead:
45
- *
46
- * ```ts
47
- * const debouncer = injectAsyncDebouncer(fn, {
48
- * wait: 500,
49
- * onUnmount: (d) => d.flush()
50
- * });
51
- * ```
52
- *
53
- * When using onUnmount with flush, guard your callbacks since the component may already be destroyed.
54
- *
55
- * @example
56
- * ```ts
57
- * // Default behavior - no reactive state subscriptions
58
- * const debouncer = injectAsyncDebouncer(
59
- * async (query: string) => {
60
- * const response = await fetch(`/api/search?q=${query}`);
61
- * return response.json();
62
- * },
63
- * { wait: 500 }
64
- * );
65
- *
66
- * // Opt-in to track isExecuting changes (optimized for loading states)
67
- * const debouncer = injectAsyncDebouncer(
68
- * async (query: string) => fetchSearchResults(query),
69
- * { wait: 500 },
70
- * (state) => ({ isExecuting: state.isExecuting, isPending: state.isPending })
71
- * );
72
- *
73
- * // In an event handler
74
- * const handleChange = async (e: Event) => {
75
- * const target = e.target as HTMLInputElement;
76
- * const result = await debouncer.maybeExecute(target.value);
77
- * console.log('Search results:', result);
78
- * };
79
- *
80
- * // Access the selected state
81
- * const { isExecuting, errorCount } = debouncer.state();
82
- * ```
83
- */
84
- function injectAsyncDebouncer(fn, options, selector = () => ({})) {
85
- const mergedOptions = {
86
- ...require_pacer_context.injectPacerOptions().asyncDebouncer,
87
- ...options
88
- };
89
- const debouncer = new _tanstack_pacer_async_debouncer.AsyncDebouncer(fn, mergedOptions);
90
- const state = (0, _tanstack_angular_store.injectSelector)(debouncer.store, selector);
91
- const result = {
92
- ...debouncer,
93
- state
94
- };
95
- (0, _angular_core.inject)(_angular_core.DestroyRef, { optional: true })?.onDestroy(() => {
96
- if (mergedOptions.onUnmount) mergedOptions.onUnmount(result);
97
- else {
98
- debouncer.cancel();
99
- debouncer.abort();
100
- }
101
- });
102
- return result;
103
- }
104
-
105
- //#endregion
106
- exports.injectAsyncDebouncer = injectAsyncDebouncer;
107
- //# sourceMappingURL=injectAsyncDebouncer.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectAsyncDebouncer.cjs","names":["injectPacerOptions","AsyncDebouncer","injectSelector","inject","DestroyRef"],"sources":["../../src/async-debouncer/injectAsyncDebouncer.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { AsyncDebouncer } from '@tanstack/pacer/async-debouncer'\nimport { injectPacerOptions } from '../provider/pacer-context'\nimport type { Signal } from '@angular/core'\nimport type { Store } from '@tanstack/angular-store'\nimport type { AnyAsyncFunction } from '@tanstack/pacer/types'\nimport type {\n AsyncDebouncerOptions,\n AsyncDebouncerState,\n} from '@tanstack/pacer/async-debouncer'\n\nexport interface AngularAsyncDebouncerOptions<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n> extends AsyncDebouncerOptions<TFn> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the debouncer instance.\n * When provided, replaces the default cleanup (cancel + abort); use it to call flush(), cancel(), add logging, etc.\n * When using onUnmount with flush, guard your callbacks since the component may already be destroyed.\n */\n onUnmount?: (debouncer: AngularAsyncDebouncer<TFn, TSelected>) => void\n}\n\nexport interface AngularAsyncDebouncer<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n> extends Omit<AsyncDebouncer<TFn>, 'store'> {\n /**\n * Reactive state signal that will be updated when the async 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<AsyncDebouncerState<TFn>>>\n}\n\n/**\n * An Angular function that creates and manages an AsyncDebouncer instance.\n *\n * This is a lower-level function that provides direct access to the AsyncDebouncer's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * This function provides async debouncing functionality with promise support, error handling,\n * retry capabilities, and abort support.\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 * - `errorCount`: Number of function executions that have resulted in errors\n * - `isExecuting`: Whether the debounced function is currently executing asynchronously\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 * - `lastResult`: The result from the most recent successful function execution\n * - `settleCount`: Number of function executions that have completed (either successfully or with errors)\n * - `status`: Current execution status ('disabled' | 'idle' | 'pending' | 'executing' | 'settled')\n * - `successCount`: Number of function executions that have completed successfully\n *\n * ## Cleanup on Destroy\n *\n * By default, the function cancels any pending execution and aborts in-flight work 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 = injectAsyncDebouncer(fn, {\n * wait: 500,\n * onUnmount: (d) => d.flush()\n * });\n * ```\n *\n * When using onUnmount with flush, guard your callbacks since the component may already be destroyed.\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const debouncer = injectAsyncDebouncer(\n * async (query: string) => {\n * const response = await fetch(`/api/search?q=${query}`);\n * return response.json();\n * },\n * { wait: 500 }\n * );\n *\n * // Opt-in to track isExecuting changes (optimized for loading states)\n * const debouncer = injectAsyncDebouncer(\n * async (query: string) => fetchSearchResults(query),\n * { wait: 500 },\n * (state) => ({ isExecuting: state.isExecuting, isPending: state.isPending })\n * );\n *\n * // In an event handler\n * const handleChange = async (e: Event) => {\n * const target = e.target as HTMLInputElement;\n * const result = await debouncer.maybeExecute(target.value);\n * console.log('Search results:', result);\n * };\n *\n * // Access the selected state\n * const { isExecuting, errorCount } = debouncer.state();\n * ```\n */\nexport function injectAsyncDebouncer<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n>(\n fn: TFn,\n options: AngularAsyncDebouncerOptions<TFn, TSelected>,\n selector: (state: AsyncDebouncerState<TFn>) => TSelected = () =>\n ({}) as TSelected,\n): AngularAsyncDebouncer<TFn, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().asyncDebouncer,\n ...options,\n } as AngularAsyncDebouncerOptions<TFn, TSelected>\n\n const debouncer = new AsyncDebouncer<TFn>(fn, mergedOptions)\n const state = injectSelector(debouncer.store, selector)\n\n const result = {\n ...debouncer,\n state,\n } as AngularAsyncDebouncer<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 debouncer.abort()\n }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsHA,SAAgB,qBAId,IACA,SACA,kBACG,CAAC,IACmC;CACvC,MAAM,gBAAgB;EACpB,GAAGA,yCAAmB,CAAC,CAAC;EACxB,GAAG;CACL;CAEA,MAAM,YAAY,IAAIC,+CAAoB,IAAI,aAAa;CAC3D,MAAM,YAAQC,wCAAe,UAAU,OAAO,QAAQ;CAEtD,MAAM,SAAS;EACb,GAAG;EACH;CACF;CAGA,IADmBC,sBAAOC,0BAAY,EAAE,UAAU,KAAK,CAC9C,CAAC,EAAE,gBAAgB;EAC1B,IAAI,cAAc,WAChB,cAAc,UAAU,MAAM;OACzB;GACL,UAAU,OAAO;GACjB,UAAU,MAAM;EAClB;CACF,CAAC;CAED,OAAO;AACT"}
@@ -1,107 +0,0 @@
1
- import { Signal } from "@angular/core";
2
- import { Store } from "@tanstack/angular-store";
3
- import { AsyncDebouncer, AsyncDebouncerOptions, AsyncDebouncerState } from "@tanstack/pacer/async-debouncer";
4
- import { AnyAsyncFunction } from "@tanstack/pacer/types";
5
- //#region src/async-debouncer/injectAsyncDebouncer.d.ts
6
- interface AngularAsyncDebouncerOptions<TFn extends AnyAsyncFunction, TSelected = {}> extends AsyncDebouncerOptions<TFn> {
7
- /**
8
- * Optional callback invoked when the component is destroyed. Receives the debouncer instance.
9
- * When provided, replaces the default cleanup (cancel + abort); use it to call flush(), cancel(), add logging, etc.
10
- * When using onUnmount with flush, guard your callbacks since the component may already be destroyed.
11
- */
12
- onUnmount?: (debouncer: AngularAsyncDebouncer<TFn, TSelected>) => void;
13
- }
14
- interface AngularAsyncDebouncer<TFn extends AnyAsyncFunction, TSelected = {}> extends Omit<AsyncDebouncer<TFn>, 'store'> {
15
- /**
16
- * Reactive state signal that will be updated when the async 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<AsyncDebouncerState<TFn>>>;
26
- }
27
- /**
28
- * An Angular function that creates and manages an AsyncDebouncer instance.
29
- *
30
- * This is a lower-level function that provides direct access to the AsyncDebouncer's functionality.
31
- * This allows you to integrate it with any state management solution you prefer.
32
- *
33
- * This function provides async debouncing functionality with promise support, error handling,
34
- * retry capabilities, and abort support.
35
- *
36
- * The debouncer will only execute the function after the specified wait time has elapsed
37
- * since the last call. If the function is called again before the wait time expires, the
38
- * timer resets and starts waiting again.
39
- *
40
- * ## State Management and Selector
41
- *
42
- * The function uses TanStack Store for state management and wraps it with Angular signals.
43
- * The `selector` parameter allows you to specify which state changes will trigger signal updates,
44
- * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.
45
- *
46
- * **By default, there will be no reactive state subscriptions** and you must opt-in to state
47
- * tracking by providing a selector function. This prevents unnecessary updates and gives you
48
- * full control over when your component tracks state changes.
49
- *
50
- * Available state properties:
51
- * - `canLeadingExecute`: Whether the debouncer can execute on the leading edge
52
- * - `errorCount`: Number of function executions that have resulted in errors
53
- * - `isExecuting`: Whether the debounced function is currently executing asynchronously
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
- * - `lastResult`: The result from the most recent successful function execution
57
- * - `settleCount`: Number of function executions that have completed (either successfully or with errors)
58
- * - `status`: Current execution status ('disabled' | 'idle' | 'pending' | 'executing' | 'settled')
59
- * - `successCount`: Number of function executions that have completed successfully
60
- *
61
- * ## Cleanup on Destroy
62
- *
63
- * By default, the function cancels any pending execution and aborts in-flight work when the component is destroyed.
64
- * Use the `onUnmount` option to customize this. For example, to flush pending work instead:
65
- *
66
- * ```ts
67
- * const debouncer = injectAsyncDebouncer(fn, {
68
- * wait: 500,
69
- * onUnmount: (d) => d.flush()
70
- * });
71
- * ```
72
- *
73
- * When using onUnmount with flush, guard your callbacks since the component may already be destroyed.
74
- *
75
- * @example
76
- * ```ts
77
- * // Default behavior - no reactive state subscriptions
78
- * const debouncer = injectAsyncDebouncer(
79
- * async (query: string) => {
80
- * const response = await fetch(`/api/search?q=${query}`);
81
- * return response.json();
82
- * },
83
- * { wait: 500 }
84
- * );
85
- *
86
- * // Opt-in to track isExecuting changes (optimized for loading states)
87
- * const debouncer = injectAsyncDebouncer(
88
- * async (query: string) => fetchSearchResults(query),
89
- * { wait: 500 },
90
- * (state) => ({ isExecuting: state.isExecuting, isPending: state.isPending })
91
- * );
92
- *
93
- * // In an event handler
94
- * const handleChange = async (e: Event) => {
95
- * const target = e.target as HTMLInputElement;
96
- * const result = await debouncer.maybeExecute(target.value);
97
- * console.log('Search results:', result);
98
- * };
99
- *
100
- * // Access the selected state
101
- * const { isExecuting, errorCount } = debouncer.state();
102
- * ```
103
- */
104
- declare function injectAsyncDebouncer<TFn extends AnyAsyncFunction, TSelected = {}>(fn: TFn, options: AngularAsyncDebouncerOptions<TFn, TSelected>, selector?: (state: AsyncDebouncerState<TFn>) => TSelected): AngularAsyncDebouncer<TFn, TSelected>;
105
- //#endregion
106
- export { AngularAsyncDebouncer, AngularAsyncDebouncerOptions, injectAsyncDebouncer };
107
- //# sourceMappingURL=injectAsyncDebouncer.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectAsyncDebouncer.js","names":[],"sources":["../../src/async-debouncer/injectAsyncDebouncer.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { AsyncDebouncer } from '@tanstack/pacer/async-debouncer'\nimport { injectPacerOptions } from '../provider/pacer-context'\nimport type { Signal } from '@angular/core'\nimport type { Store } from '@tanstack/angular-store'\nimport type { AnyAsyncFunction } from '@tanstack/pacer/types'\nimport type {\n AsyncDebouncerOptions,\n AsyncDebouncerState,\n} from '@tanstack/pacer/async-debouncer'\n\nexport interface AngularAsyncDebouncerOptions<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n> extends AsyncDebouncerOptions<TFn> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the debouncer instance.\n * When provided, replaces the default cleanup (cancel + abort); use it to call flush(), cancel(), add logging, etc.\n * When using onUnmount with flush, guard your callbacks since the component may already be destroyed.\n */\n onUnmount?: (debouncer: AngularAsyncDebouncer<TFn, TSelected>) => void\n}\n\nexport interface AngularAsyncDebouncer<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n> extends Omit<AsyncDebouncer<TFn>, 'store'> {\n /**\n * Reactive state signal that will be updated when the async 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<AsyncDebouncerState<TFn>>>\n}\n\n/**\n * An Angular function that creates and manages an AsyncDebouncer instance.\n *\n * This is a lower-level function that provides direct access to the AsyncDebouncer's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * This function provides async debouncing functionality with promise support, error handling,\n * retry capabilities, and abort support.\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 * - `errorCount`: Number of function executions that have resulted in errors\n * - `isExecuting`: Whether the debounced function is currently executing asynchronously\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 * - `lastResult`: The result from the most recent successful function execution\n * - `settleCount`: Number of function executions that have completed (either successfully or with errors)\n * - `status`: Current execution status ('disabled' | 'idle' | 'pending' | 'executing' | 'settled')\n * - `successCount`: Number of function executions that have completed successfully\n *\n * ## Cleanup on Destroy\n *\n * By default, the function cancels any pending execution and aborts in-flight work 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 = injectAsyncDebouncer(fn, {\n * wait: 500,\n * onUnmount: (d) => d.flush()\n * });\n * ```\n *\n * When using onUnmount with flush, guard your callbacks since the component may already be destroyed.\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const debouncer = injectAsyncDebouncer(\n * async (query: string) => {\n * const response = await fetch(`/api/search?q=${query}`);\n * return response.json();\n * },\n * { wait: 500 }\n * );\n *\n * // Opt-in to track isExecuting changes (optimized for loading states)\n * const debouncer = injectAsyncDebouncer(\n * async (query: string) => fetchSearchResults(query),\n * { wait: 500 },\n * (state) => ({ isExecuting: state.isExecuting, isPending: state.isPending })\n * );\n *\n * // In an event handler\n * const handleChange = async (e: Event) => {\n * const target = e.target as HTMLInputElement;\n * const result = await debouncer.maybeExecute(target.value);\n * console.log('Search results:', result);\n * };\n *\n * // Access the selected state\n * const { isExecuting, errorCount } = debouncer.state();\n * ```\n */\nexport function injectAsyncDebouncer<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n>(\n fn: TFn,\n options: AngularAsyncDebouncerOptions<TFn, TSelected>,\n selector: (state: AsyncDebouncerState<TFn>) => TSelected = () =>\n ({}) as TSelected,\n): AngularAsyncDebouncer<TFn, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().asyncDebouncer,\n ...options,\n } as AngularAsyncDebouncerOptions<TFn, TSelected>\n\n const debouncer = new AsyncDebouncer<TFn>(fn, mergedOptions)\n const state = injectSelector(debouncer.store, selector)\n\n const result = {\n ...debouncer,\n state,\n } as AngularAsyncDebouncer<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 debouncer.abort()\n }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsHA,SAAgB,qBAId,IACA,SACA,kBACG,CAAC,IACmC;CACvC,MAAM,gBAAgB;EACpB,GAAG,mBAAmB,CAAC,CAAC;EACxB,GAAG;CACL;CAEA,MAAM,YAAY,IAAI,eAAoB,IAAI,aAAa;CAC3D,MAAM,QAAQ,eAAe,UAAU,OAAO,QAAQ;CAEtD,MAAM,SAAS;EACb,GAAG;EACH;CACF;CAGA,AADmB,OAAO,YAAY,EAAE,UAAU,KAAK,CAC9C,CAAC,EAAE,gBAAgB;EAC1B,IAAI,cAAc,WAChB,cAAc,UAAU,MAAM;OACzB;GACL,UAAU,OAAO;GACjB,UAAU,MAAM;EAClB;CACF,CAAC;CAED,OAAO;AACT"}
@@ -1,13 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_injectAsyncQueuer = require('./injectAsyncQueuer.cjs');
3
- const require_injectAsyncQueuedSignal = require('./injectAsyncQueuedSignal.cjs');
4
-
5
- exports.injectAsyncQueuedSignal = require_injectAsyncQueuedSignal.injectAsyncQueuedSignal;
6
- exports.injectAsyncQueuer = require_injectAsyncQueuer.injectAsyncQueuer;
7
- var _tanstack_pacer_async_queuer = require("@tanstack/pacer/async-queuer");
8
- Object.keys(_tanstack_pacer_async_queuer).forEach(function (k) {
9
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
10
- enumerable: true,
11
- get: function () { return _tanstack_pacer_async_queuer[k]; }
12
- });
13
- });
@@ -1,4 +0,0 @@
1
- import { AngularAsyncQueuer, AngularAsyncQueuerOptions, injectAsyncQueuer } from "./injectAsyncQueuer.cjs";
2
- import { AsyncQueuedSignal, injectAsyncQueuedSignal } from "./injectAsyncQueuedSignal.cjs";
3
- export * from "@tanstack/pacer/async-queuer";
4
- export { AngularAsyncQueuer, AngularAsyncQueuerOptions, AsyncQueuedSignal, injectAsyncQueuedSignal, injectAsyncQueuer };
@@ -1,53 +0,0 @@
1
- const require_injectAsyncQueuer = require('./injectAsyncQueuer.cjs');
2
- let _angular_core = require("@angular/core");
3
-
4
- //#region src/async-queuer/injectAsyncQueuedSignal.ts
5
- /**
6
- * An Angular function that creates an async queuer with managed state, combining Angular's signals with async queuing functionality.
7
- * This function provides both the current queue state and queue control methods.
8
- *
9
- * The queue state is automatically updated whenever items are added, removed, or processed in the queue.
10
- * All queue operations are reflected in the state array returned by the function.
11
- *
12
- * The function returns a callable object:
13
- * - `queued()`: Get the current queue items as an array
14
- * - `queued.addItem(...)`: Add an item to the queue
15
- * - `queued.queue`: The queuer instance with additional control methods
16
- *
17
- * @example
18
- * ```ts
19
- * // Default behavior - track items
20
- * const queued = injectAsyncQueuedSignal(
21
- * async (item) => {
22
- * const response = await fetch('/api/process', {
23
- * method: 'POST',
24
- * body: JSON.stringify(item)
25
- * });
26
- * return response.json();
27
- * },
28
- * { concurrency: 2, wait: 1000 }
29
- * );
30
- *
31
- * // Add items
32
- * queued.addItem(data1);
33
- *
34
- * // Access items
35
- * console.log(queued()); // [data1, ...]
36
- *
37
- * // Control the queue
38
- * queued.queuer.start();
39
- * queued.queuer.stop();
40
- * ```
41
- */
42
- function injectAsyncQueuedSignal(fn, options = {}, selector = (state) => ({ items: state.items })) {
43
- const queuer = require_injectAsyncQueuer.injectAsyncQueuer(fn, options, selector);
44
- const items = (0, _angular_core.computed)(() => queuer.state().items);
45
- return Object.assign(items, {
46
- addItem: queuer.addItem.bind(queuer),
47
- queuer
48
- });
49
- }
50
-
51
- //#endregion
52
- exports.injectAsyncQueuedSignal = injectAsyncQueuedSignal;
53
- //# sourceMappingURL=injectAsyncQueuedSignal.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectAsyncQueuedSignal.cjs","names":["injectAsyncQueuer","computed"],"sources":["../../src/async-queuer/injectAsyncQueuedSignal.ts"],"sourcesContent":["import { computed } from '@angular/core'\nimport { injectAsyncQueuer } from './injectAsyncQueuer'\nimport type { AngularAsyncQueuer } from './injectAsyncQueuer'\nimport type {\n AsyncQueuerOptions,\n AsyncQueuerState,\n} from '@tanstack/pacer/async-queuer'\n\nexport interface AsyncQueuedSignal<TValue, TSelected = {}> {\n (): Array<TValue>\n addItem: AngularAsyncQueuer<TValue, TSelected>['addItem']\n queuer: AngularAsyncQueuer<TValue, TSelected>\n}\n\n/**\n * An Angular function that creates an async queuer with managed state, combining Angular's signals with async queuing functionality.\n * This function provides both the current queue state and queue control methods.\n *\n * The queue state is automatically updated whenever items are added, removed, or processed in the queue.\n * All queue operations are reflected in the state array returned by the function.\n *\n * The function returns a callable object:\n * - `queued()`: Get the current queue items as an array\n * - `queued.addItem(...)`: Add an item to the queue\n * - `queued.queue`: The queuer instance with additional control methods\n *\n * @example\n * ```ts\n * // Default behavior - track items\n * const queued = injectAsyncQueuedSignal(\n * async (item) => {\n * const response = await fetch('/api/process', {\n * method: 'POST',\n * body: JSON.stringify(item)\n * });\n * return response.json();\n * },\n * { concurrency: 2, wait: 1000 }\n * );\n *\n * // Add items\n * queued.addItem(data1);\n *\n * // Access items\n * console.log(queued()); // [data1, ...]\n *\n * // Control the queue\n * queued.queuer.start();\n * queued.queuer.stop();\n * ```\n */\nexport function injectAsyncQueuedSignal<\n TValue,\n TSelected extends Pick<AsyncQueuerState<TValue>, 'items'> = Pick<\n AsyncQueuerState<TValue>,\n 'items'\n >,\n>(\n fn: (value: TValue) => Promise<any>,\n options: AsyncQueuerOptions<TValue> = {},\n selector: (state: AsyncQueuerState<TValue>) => TSelected = (state) =>\n ({ items: state.items }) as TSelected,\n): AsyncQueuedSignal<TValue, TSelected> {\n const queuer = injectAsyncQueuer(fn, options, selector)\n\n const items = computed(() => queuer.state().items as Array<TValue>)\n\n const queued = Object.assign(items, {\n addItem: queuer.addItem.bind(queuer),\n queuer,\n }) as AsyncQueuedSignal<TValue, TSelected>\n\n return queued\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,SAAgB,wBAOd,IACA,UAAsC,CAAC,GACvC,YAA4D,WACzD,EAAE,OAAO,MAAM,MAAM,IACc;CACtC,MAAM,SAASA,4CAAkB,IAAI,SAAS,QAAQ;CAEtD,MAAM,YAAQC,8BAAe,OAAO,MAAM,CAAC,CAAC,KAAsB;CAOlE,OALe,OAAO,OAAO,OAAO;EAClC,SAAS,OAAO,QAAQ,KAAK,MAAM;EACnC;CACF,CAEY;AACd"}
@@ -1,49 +0,0 @@
1
- import { AngularAsyncQueuer } from "./injectAsyncQueuer.cjs";
2
- import { AsyncQueuerOptions, AsyncQueuerState } from "@tanstack/pacer/async-queuer";
3
- //#region src/async-queuer/injectAsyncQueuedSignal.d.ts
4
- interface AsyncQueuedSignal<TValue, TSelected = {}> {
5
- (): Array<TValue>;
6
- addItem: AngularAsyncQueuer<TValue, TSelected>['addItem'];
7
- queuer: AngularAsyncQueuer<TValue, TSelected>;
8
- }
9
- /**
10
- * An Angular function that creates an async queuer with managed state, combining Angular's signals with async queuing functionality.
11
- * This function provides both the current queue state and queue control methods.
12
- *
13
- * The queue state is automatically updated whenever items are added, removed, or processed in the queue.
14
- * All queue operations are reflected in the state array returned by the function.
15
- *
16
- * The function returns a callable object:
17
- * - `queued()`: Get the current queue items as an array
18
- * - `queued.addItem(...)`: Add an item to the queue
19
- * - `queued.queue`: The queuer instance with additional control methods
20
- *
21
- * @example
22
- * ```ts
23
- * // Default behavior - track items
24
- * const queued = injectAsyncQueuedSignal(
25
- * async (item) => {
26
- * const response = await fetch('/api/process', {
27
- * method: 'POST',
28
- * body: JSON.stringify(item)
29
- * });
30
- * return response.json();
31
- * },
32
- * { concurrency: 2, wait: 1000 }
33
- * );
34
- *
35
- * // Add items
36
- * queued.addItem(data1);
37
- *
38
- * // Access items
39
- * console.log(queued()); // [data1, ...]
40
- *
41
- * // Control the queue
42
- * queued.queuer.start();
43
- * queued.queuer.stop();
44
- * ```
45
- */
46
- declare function injectAsyncQueuedSignal<TValue, TSelected extends Pick<AsyncQueuerState<TValue>, 'items'> = Pick<AsyncQueuerState<TValue>, 'items'>>(fn: (value: TValue) => Promise<any>, options?: AsyncQueuerOptions<TValue>, selector?: (state: AsyncQueuerState<TValue>) => TSelected): AsyncQueuedSignal<TValue, TSelected>;
47
- //#endregion
48
- export { AsyncQueuedSignal, injectAsyncQueuedSignal };
49
- //# sourceMappingURL=injectAsyncQueuedSignal.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectAsyncQueuedSignal.js","names":[],"sources":["../../src/async-queuer/injectAsyncQueuedSignal.ts"],"sourcesContent":["import { computed } from '@angular/core'\nimport { injectAsyncQueuer } from './injectAsyncQueuer'\nimport type { AngularAsyncQueuer } from './injectAsyncQueuer'\nimport type {\n AsyncQueuerOptions,\n AsyncQueuerState,\n} from '@tanstack/pacer/async-queuer'\n\nexport interface AsyncQueuedSignal<TValue, TSelected = {}> {\n (): Array<TValue>\n addItem: AngularAsyncQueuer<TValue, TSelected>['addItem']\n queuer: AngularAsyncQueuer<TValue, TSelected>\n}\n\n/**\n * An Angular function that creates an async queuer with managed state, combining Angular's signals with async queuing functionality.\n * This function provides both the current queue state and queue control methods.\n *\n * The queue state is automatically updated whenever items are added, removed, or processed in the queue.\n * All queue operations are reflected in the state array returned by the function.\n *\n * The function returns a callable object:\n * - `queued()`: Get the current queue items as an array\n * - `queued.addItem(...)`: Add an item to the queue\n * - `queued.queue`: The queuer instance with additional control methods\n *\n * @example\n * ```ts\n * // Default behavior - track items\n * const queued = injectAsyncQueuedSignal(\n * async (item) => {\n * const response = await fetch('/api/process', {\n * method: 'POST',\n * body: JSON.stringify(item)\n * });\n * return response.json();\n * },\n * { concurrency: 2, wait: 1000 }\n * );\n *\n * // Add items\n * queued.addItem(data1);\n *\n * // Access items\n * console.log(queued()); // [data1, ...]\n *\n * // Control the queue\n * queued.queuer.start();\n * queued.queuer.stop();\n * ```\n */\nexport function injectAsyncQueuedSignal<\n TValue,\n TSelected extends Pick<AsyncQueuerState<TValue>, 'items'> = Pick<\n AsyncQueuerState<TValue>,\n 'items'\n >,\n>(\n fn: (value: TValue) => Promise<any>,\n options: AsyncQueuerOptions<TValue> = {},\n selector: (state: AsyncQueuerState<TValue>) => TSelected = (state) =>\n ({ items: state.items }) as TSelected,\n): AsyncQueuedSignal<TValue, TSelected> {\n const queuer = injectAsyncQueuer(fn, options, selector)\n\n const items = computed(() => queuer.state().items as Array<TValue>)\n\n const queued = Object.assign(items, {\n addItem: queuer.addItem.bind(queuer),\n queuer,\n }) as AsyncQueuedSignal<TValue, TSelected>\n\n return queued\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,SAAgB,wBAOd,IACA,UAAsC,CAAC,GACvC,YAA4D,WACzD,EAAE,OAAO,MAAM,MAAM,IACc;CACtC,MAAM,SAAS,kBAAkB,IAAI,SAAS,QAAQ;CAEtD,MAAM,QAAQ,eAAe,OAAO,MAAM,CAAC,CAAC,KAAsB;CAOlE,OALe,OAAO,OAAO,OAAO;EAClC,SAAS,OAAO,QAAQ,KAAK,MAAM;EACnC;CACF,CAEY;AACd"}