@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
@@ -35,7 +35,5 @@ import { AnyFunction } from "@tanstack/pacer/types";
35
35
  * );
36
36
  * ```
37
37
  */
38
- declare function injectRateLimitedCallback<TFn extends AnyFunction>(fn: TFn, options: RateLimiterOptions<TFn>): (...args: Parameters<TFn>) => boolean;
39
- //#endregion
40
- export { injectRateLimitedCallback };
41
- //# sourceMappingURL=injectRateLimitedCallback.d.ts.map
38
+ export declare function injectRateLimitedCallback<TFn extends AnyFunction>(fn: TFn, options: RateLimiterOptions<TFn>): (...args: Parameters<TFn>) => boolean;
39
+ //#endregion
@@ -41,5 +41,4 @@ function injectRateLimitedCallback(fn, options) {
41
41
  }
42
42
 
43
43
  //#endregion
44
- export { injectRateLimitedCallback };
45
- //# sourceMappingURL=injectRateLimitedCallback.js.map
44
+ export { injectRateLimitedCallback };
@@ -2,7 +2,7 @@ import { AngularRateLimiter } from "./injectRateLimiter.js";
2
2
  import { RateLimiterOptions, RateLimiterState } from "@tanstack/pacer/rate-limiter";
3
3
  //#region src/rate-limiter/injectRateLimitedSignal.d.ts
4
4
  type Setter<T> = (value: T | ((prev: T) => T)) => void;
5
- interface RateLimitedSignal<TValue, TSelected = {}> {
5
+ export interface RateLimitedSignal<TValue, TSelected = {}> {
6
6
  (): TValue;
7
7
  set: Setter<TValue>;
8
8
  rateLimiter: AngularRateLimiter<Setter<TValue>, TSelected>;
@@ -47,7 +47,5 @@ interface RateLimitedSignal<TValue, TSelected = {}> {
47
47
  * );
48
48
  * ```
49
49
  */
50
- declare function injectRateLimitedSignal<TValue, TSelected = {}>(value: TValue, initialOptions: RateLimiterOptions<Setter<TValue>>, selector?: (state: RateLimiterState) => TSelected): RateLimitedSignal<TValue, TSelected>;
51
- //#endregion
52
- export { RateLimitedSignal, injectRateLimitedSignal };
53
- //# sourceMappingURL=injectRateLimitedSignal.d.ts.map
50
+ export declare function injectRateLimitedSignal<TValue, TSelected = {}>(value: TValue, initialOptions: RateLimiterOptions<Setter<TValue>>, selector?: (state: RateLimiterState) => TSelected): RateLimitedSignal<TValue, TSelected>;
51
+ //#endregion
@@ -58,5 +58,4 @@ function injectRateLimitedSignal(value, initialOptions, selector) {
58
58
  }
59
59
 
60
60
  //#endregion
61
- export { injectRateLimitedSignal };
62
- //# sourceMappingURL=injectRateLimitedSignal.js.map
61
+ export { injectRateLimitedSignal };
@@ -41,8 +41,6 @@ type Setter<T> = (value: T | ((prev: T) => T)) => void;
41
41
  * })
42
42
  * ```
43
43
  */
44
- declare function injectRateLimitedValue<TValue, TSelected = {}>(value: Signal<TValue>, initialOptions: RateLimiterOptions<Setter<TValue>>, selector?: (state: RateLimiterState) => TSelected): RateLimitedSignal<TValue, TSelected>;
45
- declare function injectRateLimitedValue<TValue, TSelected = {}>(value: Signal<TValue>, initialValue: TValue, initialOptions: RateLimiterOptions<Setter<TValue>>, selector?: (state: RateLimiterState) => TSelected): RateLimitedSignal<TValue, TSelected>;
46
- //#endregion
47
- export { injectRateLimitedValue };
48
- //# sourceMappingURL=injectRateLimitedValue.d.ts.map
44
+ export declare function injectRateLimitedValue<TValue, TSelected = {}>(value: Signal<TValue>, initialOptions: RateLimiterOptions<Setter<TValue>>, selector?: (state: RateLimiterState) => TSelected): RateLimitedSignal<TValue, TSelected>;
45
+ export declare function injectRateLimitedValue<TValue, TSelected = {}>(value: Signal<TValue>, initialValue: TValue, initialOptions: RateLimiterOptions<Setter<TValue>>, selector?: (state: RateLimiterState) => TSelected): RateLimitedSignal<TValue, TSelected>;
46
+ //#endregion
@@ -13,5 +13,4 @@ function injectRateLimitedValue(value, initialValueOrOptions, initialOptionsOrSe
13
13
  }
14
14
 
15
15
  //#endregion
16
- export { injectRateLimitedValue };
17
- //# sourceMappingURL=injectRateLimitedValue.js.map
16
+ export { injectRateLimitedValue };
@@ -3,13 +3,13 @@ import { Store } from "@tanstack/angular-store";
3
3
  import { RateLimiter, RateLimiterOptions, RateLimiterState } from "@tanstack/pacer/rate-limiter";
4
4
  import { AnyFunction } from "@tanstack/pacer/types";
5
5
  //#region src/rate-limiter/injectRateLimiter.d.ts
6
- interface AngularRateLimiterOptions<TFn extends AnyFunction, TSelected = {}> extends RateLimiterOptions<TFn> {
6
+ export interface AngularRateLimiterOptions<TFn extends AnyFunction, TSelected = {}> extends RateLimiterOptions<TFn> {
7
7
  /**
8
8
  * Optional callback invoked when the component is destroyed. Receives the rate limiter instance.
9
9
  */
10
10
  onUnmount?: (rateLimiter: AngularRateLimiter<TFn, TSelected>) => void;
11
11
  }
12
- interface AngularRateLimiter<TFn extends AnyFunction, TSelected = {}> extends Omit<RateLimiter<TFn>, 'store'> {
12
+ export interface AngularRateLimiter<TFn extends AnyFunction, TSelected = {}> extends Omit<RateLimiter<TFn>, 'store'> {
13
13
  /**
14
14
  * Reactive state signal that will be updated when the rate limiter state changes
15
15
  *
@@ -96,7 +96,5 @@ interface AngularRateLimiter<TFn extends AnyFunction, TSelected = {}> extends Om
96
96
  * const { executionCount, rejectionCount } = rateLimiter.state();
97
97
  * ```
98
98
  */
99
- declare function injectRateLimiter<TFn extends AnyFunction, TSelected = {}>(fn: TFn, options: AngularRateLimiterOptions<TFn, TSelected>, selector?: (state: RateLimiterState) => TSelected): AngularRateLimiter<TFn, TSelected>;
100
- //#endregion
101
- export { AngularRateLimiter, AngularRateLimiterOptions, injectRateLimiter };
102
- //# sourceMappingURL=injectRateLimiter.d.ts.map
99
+ export declare function injectRateLimiter<TFn extends AnyFunction, TSelected = {}>(fn: TFn, options: AngularRateLimiterOptions<TFn, TSelected>, selector?: (state: RateLimiterState) => TSelected): AngularRateLimiter<TFn, TSelected>;
100
+ //#endregion
@@ -96,5 +96,4 @@ function injectRateLimiter(fn, options, selector = () => ({})) {
96
96
  }
97
97
 
98
98
  //#endregion
99
- export { injectRateLimiter };
100
- //# sourceMappingURL=injectRateLimiter.js.map
99
+ export { injectRateLimiter };
@@ -35,7 +35,5 @@ import { AnyFunction } from "@tanstack/pacer/types";
35
35
  * });
36
36
  * ```
37
37
  */
38
- declare function injectThrottledCallback<TFn extends AnyFunction>(fn: TFn, options: ThrottlerOptions<TFn>): (...args: Parameters<TFn>) => void;
39
- //#endregion
40
- export { injectThrottledCallback };
41
- //# sourceMappingURL=injectThrottledCallback.d.ts.map
38
+ export declare function injectThrottledCallback<TFn extends AnyFunction>(fn: TFn, options: ThrottlerOptions<TFn>): (...args: Parameters<TFn>) => void;
39
+ //#endregion
@@ -41,5 +41,4 @@ function injectThrottledCallback(fn, options) {
41
41
  }
42
42
 
43
43
  //#endregion
44
- export { injectThrottledCallback };
45
- //# sourceMappingURL=injectThrottledCallback.js.map
44
+ export { injectThrottledCallback };
@@ -2,7 +2,7 @@ import { AngularThrottler } from "./injectThrottler.js";
2
2
  import { ThrottlerOptions, ThrottlerState } from "@tanstack/pacer/throttler";
3
3
  //#region src/throttler/injectThrottledSignal.d.ts
4
4
  type Setter<T> = (value: T | ((prev: T) => T)) => void;
5
- interface ThrottledSignal<TValue, TSelected = {}> {
5
+ export interface ThrottledSignal<TValue, TSelected = {}> {
6
6
  (): TValue;
7
7
  set: Setter<TValue>;
8
8
  throttler: AngularThrottler<Setter<TValue>, TSelected>;
@@ -31,8 +31,6 @@ interface ThrottledSignal<TValue, TSelected = {}> {
31
31
  * full control over when your component tracks state changes.
32
32
  *
33
33
  * Available throttler state properties:
34
- * - `canLeadingExecute`: Whether the throttler can execute on the leading edge
35
- * - `canTrailingExecute`: Whether the throttler can execute on the trailing edge
36
34
  * - `executionCount`: Number of function executions that have been completed
37
35
  * - `isPending`: Whether the throttler is waiting for the timeout to trigger execution
38
36
  * - `lastArgs`: The arguments from the most recent call to maybeExecute
@@ -54,7 +52,5 @@ interface ThrottledSignal<TValue, TSelected = {}> {
54
52
  * console.log(throttledScrollY.throttler.state().isPending)
55
53
  * ```
56
54
  */
57
- declare function injectThrottledSignal<TValue, TSelected = {}>(value: TValue, initialOptions: ThrottlerOptions<Setter<TValue>>, selector?: (state: ThrottlerState<Setter<TValue>>) => TSelected): ThrottledSignal<TValue, TSelected>;
58
- //#endregion
59
- export { ThrottledSignal, injectThrottledSignal };
60
- //# sourceMappingURL=injectThrottledSignal.d.ts.map
55
+ export declare function injectThrottledSignal<TValue, TSelected = {}>(value: TValue, initialOptions: ThrottlerOptions<Setter<TValue>>, selector?: (state: ThrottlerState<Setter<TValue>>) => TSelected): ThrottledSignal<TValue, TSelected>;
56
+ //#endregion
@@ -26,8 +26,6 @@ import { signal } from "@angular/core";
26
26
  * full control over when your component tracks state changes.
27
27
  *
28
28
  * Available throttler state properties:
29
- * - `canLeadingExecute`: Whether the throttler can execute on the leading edge
30
- * - `canTrailingExecute`: Whether the throttler can execute on the trailing edge
31
29
  * - `executionCount`: Number of function executions that have been completed
32
30
  * - `isPending`: Whether the throttler is waiting for the timeout to trigger execution
33
31
  * - `lastArgs`: The arguments from the most recent call to maybeExecute
@@ -65,5 +63,4 @@ function injectThrottledSignal(value, initialOptions, selector) {
65
63
  }
66
64
 
67
65
  //#endregion
68
- export { injectThrottledSignal };
69
- //# sourceMappingURL=injectThrottledSignal.js.map
66
+ export { injectThrottledSignal };
@@ -30,8 +30,6 @@ type Setter<T> = (value: T | ((prev: T) => T)) => void;
30
30
  * full control over when your component tracks state changes.
31
31
  *
32
32
  * Available throttler state properties:
33
- * - `canLeadingExecute`: Whether the throttler can execute on the leading edge
34
- * - `canTrailingExecute`: Whether the throttler can execute on the trailing edge
35
33
  * - `executionCount`: Number of function executions that have been completed
36
34
  * - `isPending`: Whether the throttler is waiting for the timeout to trigger execution
37
35
  * - `lastArgs`: The arguments from the most recent call to maybeExecute
@@ -66,8 +64,6 @@ type Setter<T> = (value: T | ((prev: T) => T)) => void;
66
64
  * throttledScrollY.cancel() // Cancel any pending updates
67
65
  * ```
68
66
  */
69
- declare function injectThrottledValue<TValue, TSelected = {}>(value: Signal<TValue>, initialOptions: ThrottlerOptions<Setter<TValue>>, selector?: (state: ThrottlerState<Setter<TValue>>) => TSelected): ThrottledSignal<TValue, TSelected>;
70
- declare function injectThrottledValue<TValue, TSelected = {}>(value: Signal<TValue>, initialValue: TValue, initialOptions: ThrottlerOptions<Setter<TValue>>, selector?: (state: ThrottlerState<Setter<TValue>>) => TSelected): ThrottledSignal<TValue, TSelected>;
71
- //#endregion
72
- export { injectThrottledValue };
73
- //# sourceMappingURL=injectThrottledValue.d.ts.map
67
+ export declare function injectThrottledValue<TValue, TSelected = {}>(value: Signal<TValue>, initialOptions: ThrottlerOptions<Setter<TValue>>, selector?: (state: ThrottlerState<Setter<TValue>>) => TSelected): ThrottledSignal<TValue, TSelected>;
68
+ export declare function injectThrottledValue<TValue, TSelected = {}>(value: Signal<TValue>, initialValue: TValue, initialOptions: ThrottlerOptions<Setter<TValue>>, selector?: (state: ThrottlerState<Setter<TValue>>) => TSelected): ThrottledSignal<TValue, TSelected>;
69
+ //#endregion
@@ -13,5 +13,4 @@ function injectThrottledValue(value, initialValueOrOptions, initialOptionsOrSele
13
13
  }
14
14
 
15
15
  //#endregion
16
- export { injectThrottledValue };
17
- //# sourceMappingURL=injectThrottledValue.js.map
16
+ export { injectThrottledValue };
@@ -3,14 +3,14 @@ import { Store } from "@tanstack/angular-store";
3
3
  import { Throttler, ThrottlerOptions, ThrottlerState } from "@tanstack/pacer/throttler";
4
4
  import { AnyFunction } from "@tanstack/pacer/types";
5
5
  //#region src/throttler/injectThrottler.d.ts
6
- interface AngularThrottlerOptions<TFn extends AnyFunction, TSelected = {}> extends ThrottlerOptions<TFn> {
6
+ export interface AngularThrottlerOptions<TFn extends AnyFunction, TSelected = {}> extends ThrottlerOptions<TFn> {
7
7
  /**
8
8
  * Optional callback invoked when the component is destroyed. Receives the throttler instance.
9
9
  * When provided, replaces the default cleanup (cancel); use it to call flush(), cancel(), add logging, etc.
10
10
  */
11
11
  onUnmount?: (throttler: AngularThrottler<TFn, TSelected>) => void;
12
12
  }
13
- interface AngularThrottler<TFn extends AnyFunction, TSelected = {}> extends Omit<Throttler<TFn>, 'store'> {
13
+ export interface AngularThrottler<TFn extends AnyFunction, TSelected = {}> extends Omit<Throttler<TFn>, 'store'> {
14
14
  /**
15
15
  * Reactive state signal that will be updated when the throttler state changes
16
16
  *
@@ -46,8 +46,6 @@ interface AngularThrottler<TFn extends AnyFunction, TSelected = {}> extends Omit
46
46
  * full control over when your component tracks state changes.
47
47
  *
48
48
  * Available state properties:
49
- * - `canLeadingExecute`: Whether the throttler can execute on the leading edge
50
- * - `canTrailingExecute`: Whether the throttler can execute on the trailing edge
51
49
  * - `executionCount`: Number of function executions that have been completed
52
50
  * - `isPending`: Whether the throttler is waiting for the timeout to trigger execution
53
51
  * - `lastArgs`: The arguments from the most recent call to maybeExecute
@@ -91,7 +89,5 @@ interface AngularThrottler<TFn extends AnyFunction, TSelected = {}> extends Omit
91
89
  * const { isPending } = throttler.state();
92
90
  * ```
93
91
  */
94
- declare function injectThrottler<TFn extends AnyFunction, TSelected = {}>(fn: TFn, options: AngularThrottlerOptions<TFn, TSelected>, selector?: (state: ThrottlerState<TFn>) => TSelected): AngularThrottler<TFn, TSelected>;
95
- //#endregion
96
- export { AngularThrottler, AngularThrottlerOptions, injectThrottler };
97
- //# sourceMappingURL=injectThrottler.d.ts.map
92
+ export declare function injectThrottler<TFn extends AnyFunction, TSelected = {}>(fn: TFn, options: AngularThrottlerOptions<TFn, TSelected>, selector?: (state: ThrottlerState<TFn>) => TSelected): AngularThrottler<TFn, TSelected>;
93
+ //#endregion
@@ -27,8 +27,6 @@ import { Throttler } from "@tanstack/pacer/throttler";
27
27
  * full control over when your component tracks state changes.
28
28
  *
29
29
  * Available state properties:
30
- * - `canLeadingExecute`: Whether the throttler can execute on the leading edge
31
- * - `canTrailingExecute`: Whether the throttler can execute on the trailing edge
32
30
  * - `executionCount`: Number of function executions that have been completed
33
31
  * - `isPending`: Whether the throttler is waiting for the timeout to trigger execution
34
32
  * - `lastArgs`: The arguments from the most recent call to maybeExecute
@@ -91,5 +89,4 @@ function injectThrottler(fn, options, selector = () => ({})) {
91
89
  }
92
90
 
93
91
  //#endregion
94
- export { injectThrottler };
95
- //# sourceMappingURL=injectThrottler.js.map
92
+ export { injectThrottler };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/angular-pacer",
3
- "version": "0.24.0",
3
+ "version": "0.25.0",
4
4
  "description": "Utilities for debouncing and throttling functions in Angular.",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -24,87 +24,39 @@
24
24
  "signals"
25
25
  ],
26
26
  "type": "module",
27
- "main": "./dist/index.cjs",
28
- "module": "./dist/index.js",
29
- "types": "./dist/index.d.cts",
27
+ "types": "./dist/index.d.ts",
30
28
  "exports": {
31
- ".": {
32
- "import": "./dist/index.js",
33
- "require": "./dist/index.cjs"
34
- },
35
- "./async-batcher": {
36
- "import": "./dist/async-batcher/index.js",
37
- "require": "./dist/async-batcher/index.cjs"
38
- },
39
- "./async-debouncer": {
40
- "import": "./dist/async-debouncer/index.js",
41
- "require": "./dist/async-debouncer/index.cjs"
42
- },
43
- "./async-queuer": {
44
- "import": "./dist/async-queuer/index.js",
45
- "require": "./dist/async-queuer/index.cjs"
46
- },
47
- "./async-rate-limiter": {
48
- "import": "./dist/async-rate-limiter/index.js",
49
- "require": "./dist/async-rate-limiter/index.cjs"
50
- },
51
- "./async-retryer": {
52
- "import": "./dist/async-retryer/index.js",
53
- "require": "./dist/async-retryer/index.cjs"
54
- },
55
- "./async-throttler": {
56
- "import": "./dist/async-throttler/index.js",
57
- "require": "./dist/async-throttler/index.cjs"
58
- },
59
- "./batcher": {
60
- "import": "./dist/batcher/index.js",
61
- "require": "./dist/batcher/index.cjs"
62
- },
63
- "./debouncer": {
64
- "import": "./dist/debouncer/index.js",
65
- "require": "./dist/debouncer/index.cjs"
66
- },
67
- "./provider": {
68
- "import": "./dist/provider/index.js",
69
- "require": "./dist/provider/index.cjs"
70
- },
71
- "./queuer": {
72
- "import": "./dist/queuer/index.js",
73
- "require": "./dist/queuer/index.cjs"
74
- },
75
- "./rate-limiter": {
76
- "import": "./dist/rate-limiter/index.js",
77
- "require": "./dist/rate-limiter/index.cjs"
78
- },
79
- "./throttler": {
80
- "import": "./dist/throttler/index.js",
81
- "require": "./dist/throttler/index.cjs"
82
- },
83
- "./types": {
84
- "import": "./dist/types/index.js",
85
- "require": "./dist/types/index.cjs"
86
- },
87
- "./utils": {
88
- "import": "./dist/utils/index.js",
89
- "require": "./dist/utils/index.cjs"
90
- },
29
+ ".": "./dist/index.js",
30
+ "./async-batcher": "./dist/async-batcher/index.js",
31
+ "./async-debouncer": "./dist/async-debouncer/index.js",
32
+ "./async-queuer": "./dist/async-queuer/index.js",
33
+ "./async-rate-limiter": "./dist/async-rate-limiter/index.js",
34
+ "./async-retryer": "./dist/async-retryer/index.js",
35
+ "./async-throttler": "./dist/async-throttler/index.js",
36
+ "./batcher": "./dist/batcher/index.js",
37
+ "./debouncer": "./dist/debouncer/index.js",
38
+ "./provider": "./dist/provider/index.js",
39
+ "./queuer": "./dist/queuer/index.js",
40
+ "./rate-limiter": "./dist/rate-limiter/index.js",
41
+ "./throttler": "./dist/throttler/index.js",
42
+ "./types": "./dist/types/index.js",
43
+ "./utils": "./dist/utils/index.js",
91
44
  "./package.json": "./package.json"
92
45
  },
93
46
  "sideEffects": false,
94
47
  "engines": {
95
- "node": ">=18"
48
+ "node": ">=20"
96
49
  },
97
50
  "files": [
98
- "dist",
99
- "src"
51
+ "dist"
100
52
  ],
101
53
  "dependencies": {
102
54
  "@tanstack/angular-store": "^0.11.1",
103
- "@tanstack/pacer": "0.22.0"
55
+ "@tanstack/pacer": "0.23.0"
104
56
  },
105
57
  "devDependencies": {
106
- "@angular/core": "^22.1.0",
107
- "@types/node": "^26.1.2"
58
+ "@angular/core": "^22.2.0",
59
+ "@types/node": "^26.6.2"
108
60
  },
109
61
  "peerDependencies": {
110
62
  "@angular/core": ">=17.0.0"
@@ -116,6 +68,7 @@
116
68
  "test:lib": "vitest --passWithNoTests",
117
69
  "test:lib:dev": "pnpm test:lib --watch",
118
70
  "test:types": "tsc",
119
- "build": "tsdown"
71
+ "build": "tsdown",
72
+ "test:build": "publint --strict && node ../../scripts/verify-package.ts"
120
73
  }
121
74
  }
@@ -1,13 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_injectAsyncBatcher = require('./injectAsyncBatcher.cjs');
3
- const require_injectAsyncBatchedCallback = require('./injectAsyncBatchedCallback.cjs');
4
-
5
- exports.injectAsyncBatchedCallback = require_injectAsyncBatchedCallback.injectAsyncBatchedCallback;
6
- exports.injectAsyncBatcher = require_injectAsyncBatcher.injectAsyncBatcher;
7
- var _tanstack_pacer_async_batcher = require("@tanstack/pacer/async-batcher");
8
- Object.keys(_tanstack_pacer_async_batcher).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_batcher[k]; }
12
- });
13
- });
@@ -1,4 +0,0 @@
1
- import { injectAsyncBatchedCallback } from "./injectAsyncBatchedCallback.cjs";
2
- import { AngularAsyncBatcher, AngularAsyncBatcherOptions, injectAsyncBatcher } from "./injectAsyncBatcher.cjs";
3
- export * from "@tanstack/pacer/async-batcher";
4
- export { AngularAsyncBatcher, AngularAsyncBatcherOptions, injectAsyncBatchedCallback, injectAsyncBatcher };
@@ -1,49 +0,0 @@
1
- const require_injectAsyncBatcher = require('./injectAsyncBatcher.cjs');
2
-
3
- //#region src/async-batcher/injectAsyncBatchedCallback.ts
4
- /**
5
- * An Angular function that creates an async batched version of a callback function.
6
- * This function is essentially a wrapper around `injectAsyncBatcher` that provides
7
- * a simplified API for basic async batching needs.
8
- *
9
- * The batched function will collect items and process them in batches asynchronously based on
10
- * the configured conditions (maxSize, wait time, etc.).
11
- *
12
- * This function provides a simpler API compared to `injectAsyncBatcher`, making it ideal for basic
13
- * async batching needs. However, it does not expose the underlying AsyncBatcher instance.
14
- *
15
- * For advanced usage requiring features like:
16
- * - Manual flushing
17
- * - Access to batch state
18
- * - Error handling callbacks
19
- * - Retry support
20
- *
21
- * Consider using the `injectAsyncBatcher` function instead.
22
- *
23
- * @example
24
- * ```ts
25
- * // Batch async API calls
26
- * const batchApiCall = injectAsyncBatchedCallback(
27
- * async (items: Array<Data>) => {
28
- * const response = await fetch('/api/batch', {
29
- * method: 'POST',
30
- * body: JSON.stringify(items)
31
- * });
32
- * return response.json();
33
- * },
34
- * { maxSize: 10, wait: 1000 }
35
- * );
36
- *
37
- * // Items will be batched and sent together
38
- * await batchApiCall(data1);
39
- * await batchApiCall(data2);
40
- * ```
41
- */
42
- function injectAsyncBatchedCallback(fn, options) {
43
- const batcher = require_injectAsyncBatcher.injectAsyncBatcher(fn, options);
44
- return (item) => batcher.addItem(item);
45
- }
46
-
47
- //#endregion
48
- exports.injectAsyncBatchedCallback = injectAsyncBatchedCallback;
49
- //# sourceMappingURL=injectAsyncBatchedCallback.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectAsyncBatchedCallback.cjs","names":["injectAsyncBatcher"],"sources":["../../src/async-batcher/injectAsyncBatchedCallback.ts"],"sourcesContent":["import { injectAsyncBatcher } from './injectAsyncBatcher'\nimport type { AsyncBatcherOptions } from '@tanstack/pacer/async-batcher'\n\n/**\n * An Angular function that creates an async batched version of a callback function.\n * This function is essentially a wrapper around `injectAsyncBatcher` that provides\n * a simplified API for basic async batching needs.\n *\n * The batched function will collect items and process them in batches asynchronously based on\n * the configured conditions (maxSize, wait time, etc.).\n *\n * This function provides a simpler API compared to `injectAsyncBatcher`, making it ideal for basic\n * async batching needs. However, it does not expose the underlying AsyncBatcher instance.\n *\n * For advanced usage requiring features like:\n * - Manual flushing\n * - Access to batch state\n * - Error handling callbacks\n * - Retry support\n *\n * Consider using the `injectAsyncBatcher` function instead.\n *\n * @example\n * ```ts\n * // Batch async API calls\n * const batchApiCall = injectAsyncBatchedCallback(\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: 1000 }\n * );\n *\n * // Items will be batched and sent together\n * await batchApiCall(data1);\n * await batchApiCall(data2);\n * ```\n */\nexport function injectAsyncBatchedCallback<TValue>(\n fn: (items: Array<TValue>) => Promise<any>,\n options: AsyncBatcherOptions<TValue>,\n): (item: TValue) => Promise<void> {\n const batcher = injectAsyncBatcher(fn, options)\n return (item: TValue) => batcher.addItem(item)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,SAAgB,2BACd,IACA,SACiC;CACjC,MAAM,UAAUA,8CAAmB,IAAI,OAAO;CAC9C,QAAQ,SAAiB,QAAQ,QAAQ,IAAI;AAC/C"}
@@ -1,44 +0,0 @@
1
- import { AsyncBatcherOptions } from "@tanstack/pacer/async-batcher";
2
- //#region src/async-batcher/injectAsyncBatchedCallback.d.ts
3
- /**
4
- * An Angular function that creates an async batched version of a callback function.
5
- * This function is essentially a wrapper around `injectAsyncBatcher` that provides
6
- * a simplified API for basic async batching needs.
7
- *
8
- * The batched function will collect items and process them in batches asynchronously based on
9
- * the configured conditions (maxSize, wait time, etc.).
10
- *
11
- * This function provides a simpler API compared to `injectAsyncBatcher`, making it ideal for basic
12
- * async batching needs. However, it does not expose the underlying AsyncBatcher instance.
13
- *
14
- * For advanced usage requiring features like:
15
- * - Manual flushing
16
- * - Access to batch state
17
- * - Error handling callbacks
18
- * - Retry support
19
- *
20
- * Consider using the `injectAsyncBatcher` function instead.
21
- *
22
- * @example
23
- * ```ts
24
- * // Batch async API calls
25
- * const batchApiCall = injectAsyncBatchedCallback(
26
- * async (items: Array<Data>) => {
27
- * const response = await fetch('/api/batch', {
28
- * method: 'POST',
29
- * body: JSON.stringify(items)
30
- * });
31
- * return response.json();
32
- * },
33
- * { maxSize: 10, wait: 1000 }
34
- * );
35
- *
36
- * // Items will be batched and sent together
37
- * await batchApiCall(data1);
38
- * await batchApiCall(data2);
39
- * ```
40
- */
41
- declare function injectAsyncBatchedCallback<TValue>(fn: (items: Array<TValue>) => Promise<any>, options: AsyncBatcherOptions<TValue>): (item: TValue) => Promise<void>;
42
- //#endregion
43
- export { injectAsyncBatchedCallback };
44
- //# sourceMappingURL=injectAsyncBatchedCallback.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectAsyncBatchedCallback.js","names":[],"sources":["../../src/async-batcher/injectAsyncBatchedCallback.ts"],"sourcesContent":["import { injectAsyncBatcher } from './injectAsyncBatcher'\nimport type { AsyncBatcherOptions } from '@tanstack/pacer/async-batcher'\n\n/**\n * An Angular function that creates an async batched version of a callback function.\n * This function is essentially a wrapper around `injectAsyncBatcher` that provides\n * a simplified API for basic async batching needs.\n *\n * The batched function will collect items and process them in batches asynchronously based on\n * the configured conditions (maxSize, wait time, etc.).\n *\n * This function provides a simpler API compared to `injectAsyncBatcher`, making it ideal for basic\n * async batching needs. However, it does not expose the underlying AsyncBatcher instance.\n *\n * For advanced usage requiring features like:\n * - Manual flushing\n * - Access to batch state\n * - Error handling callbacks\n * - Retry support\n *\n * Consider using the `injectAsyncBatcher` function instead.\n *\n * @example\n * ```ts\n * // Batch async API calls\n * const batchApiCall = injectAsyncBatchedCallback(\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: 1000 }\n * );\n *\n * // Items will be batched and sent together\n * await batchApiCall(data1);\n * await batchApiCall(data2);\n * ```\n */\nexport function injectAsyncBatchedCallback<TValue>(\n fn: (items: Array<TValue>) => Promise<any>,\n options: AsyncBatcherOptions<TValue>,\n): (item: TValue) => Promise<void> {\n const batcher = injectAsyncBatcher(fn, options)\n return (item: TValue) => batcher.addItem(item)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,SAAgB,2BACd,IACA,SACiC;CACjC,MAAM,UAAU,mBAAmB,IAAI,OAAO;CAC9C,QAAQ,SAAiB,QAAQ,QAAQ,IAAI;AAC/C"}
@@ -1,85 +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_batcher = require("@tanstack/pacer/async-batcher");
5
-
6
- //#region src/async-batcher/injectAsyncBatcher.ts
7
- /**
8
- * An Angular function that creates and manages an AsyncBatcher instance.
9
- *
10
- * This is a lower-level function that provides direct access to the AsyncBatcher's functionality.
11
- * This allows you to integrate it with any state management solution you prefer.
12
- *
13
- * The AsyncBatcher collects items and processes them in batches asynchronously with support for
14
- * promise-based processing, error handling, retry capabilities, and abort support.
15
- *
16
- * ## State Management and Selector
17
- *
18
- * The function uses TanStack Store for state management and wraps it with Angular signals.
19
- * The `selector` parameter allows you to specify which state changes will trigger signal updates,
20
- * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.
21
- *
22
- * **By default, there will be no reactive state subscriptions** and you must opt-in to state
23
- * tracking by providing a selector function. This prevents unnecessary updates and gives you
24
- * full control over when your component tracks state changes.
25
- *
26
- * ## Cleanup on Destroy
27
- *
28
- * By default, the function cancels any pending batch and aborts in-flight work when the component is destroyed.
29
- * Use the `onUnmount` option to customize this. For example, to flush pending work instead:
30
- *
31
- * ```ts
32
- * const batcher = injectAsyncBatcher(fn, {
33
- * maxSize: 10,
34
- * onUnmount: (b) => b.flush()
35
- * });
36
- * ```
37
- *
38
- * When using onUnmount with flush, guard your callbacks since the component may already be destroyed.
39
- *
40
- * @example
41
- * ```ts
42
- * // Default behavior - no reactive state subscriptions
43
- * const batcher = injectAsyncBatcher(
44
- * async (items: Array<Data>) => {
45
- * const response = await fetch('/api/batch', {
46
- * method: 'POST',
47
- * body: JSON.stringify(items)
48
- * });
49
- * return response.json();
50
- * },
51
- * { maxSize: 10, wait: 2000 }
52
- * );
53
- *
54
- * // Add items
55
- * batcher.addItem(data1);
56
- * batcher.addItem(data2);
57
- *
58
- * // Access the selected state
59
- * const { items, isExecuting } = batcher.state();
60
- * ```
61
- */
62
- function injectAsyncBatcher(fn, options = {}, selector = () => ({})) {
63
- const mergedOptions = {
64
- ...require_pacer_context.injectPacerOptions().asyncBatcher,
65
- ...options
66
- };
67
- const batcher = new _tanstack_pacer_async_batcher.AsyncBatcher(fn, mergedOptions);
68
- const state = (0, _tanstack_angular_store.injectSelector)(batcher.store, selector);
69
- const result = {
70
- ...batcher,
71
- state
72
- };
73
- (0, _angular_core.inject)(_angular_core.DestroyRef, { optional: true })?.onDestroy(() => {
74
- if (mergedOptions.onUnmount) mergedOptions.onUnmount(result);
75
- else {
76
- batcher.cancel();
77
- batcher.abort();
78
- }
79
- });
80
- return result;
81
- }
82
-
83
- //#endregion
84
- exports.injectAsyncBatcher = injectAsyncBatcher;
85
- //# sourceMappingURL=injectAsyncBatcher.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injectAsyncBatcher.cjs","names":["injectPacerOptions","AsyncBatcher","injectSelector","inject","DestroyRef"],"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,GAAGA,yCAAmB,CAAC,CAAC;EACxB,GAAG;CACL;CAEA,MAAM,UAAU,IAAIC,2CAAqB,IAAI,aAAa;CAC1D,MAAM,YAAQC,wCAAe,QAAQ,OAAO,QAAQ;CAEpD,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,QAAQ,OAAO;GACf,QAAQ,MAAM;EAChB;CACF,CAAC;CAED,OAAO;AACT"}