@tanstack/angular-pacer 0.23.0 → 0.24.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 (125) hide show
  1. package/README.md +17 -2
  2. package/dist/async-batcher/injectAsyncBatchedCallback.cjs.map +1 -1
  3. package/dist/async-batcher/injectAsyncBatchedCallback.d.cts +0 -1
  4. package/dist/async-batcher/injectAsyncBatchedCallback.d.ts +0 -1
  5. package/dist/async-batcher/injectAsyncBatchedCallback.js.map +1 -1
  6. package/dist/async-batcher/injectAsyncBatcher.cjs.map +1 -1
  7. package/dist/async-batcher/injectAsyncBatcher.d.cts +0 -1
  8. package/dist/async-batcher/injectAsyncBatcher.d.ts +0 -1
  9. package/dist/async-batcher/injectAsyncBatcher.js.map +1 -1
  10. package/dist/async-debouncer/injectAsyncDebouncedCallback.cjs.map +1 -1
  11. package/dist/async-debouncer/injectAsyncDebouncedCallback.d.cts +0 -1
  12. package/dist/async-debouncer/injectAsyncDebouncedCallback.d.ts +0 -1
  13. package/dist/async-debouncer/injectAsyncDebouncedCallback.js.map +1 -1
  14. package/dist/async-debouncer/injectAsyncDebouncer.cjs.map +1 -1
  15. package/dist/async-debouncer/injectAsyncDebouncer.d.cts +0 -1
  16. package/dist/async-debouncer/injectAsyncDebouncer.d.ts +0 -1
  17. package/dist/async-debouncer/injectAsyncDebouncer.js.map +1 -1
  18. package/dist/async-queuer/injectAsyncQueuedSignal.cjs.map +1 -1
  19. package/dist/async-queuer/injectAsyncQueuedSignal.d.cts +0 -1
  20. package/dist/async-queuer/injectAsyncQueuedSignal.d.ts +0 -1
  21. package/dist/async-queuer/injectAsyncQueuedSignal.js.map +1 -1
  22. package/dist/async-queuer/injectAsyncQueuer.cjs.map +1 -1
  23. package/dist/async-queuer/injectAsyncQueuer.d.cts +0 -1
  24. package/dist/async-queuer/injectAsyncQueuer.d.ts +0 -1
  25. package/dist/async-queuer/injectAsyncQueuer.js.map +1 -1
  26. package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.cjs.map +1 -1
  27. package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.d.cts +0 -1
  28. package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.d.ts +0 -1
  29. package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.js.map +1 -1
  30. package/dist/async-rate-limiter/injectAsyncRateLimiter.cjs.map +1 -1
  31. package/dist/async-rate-limiter/injectAsyncRateLimiter.d.cts +0 -1
  32. package/dist/async-rate-limiter/injectAsyncRateLimiter.d.ts +0 -1
  33. package/dist/async-rate-limiter/injectAsyncRateLimiter.js.map +1 -1
  34. package/dist/async-retryer/index.cjs +0 -1
  35. package/dist/async-throttler/injectAsyncThrottledCallback.cjs.map +1 -1
  36. package/dist/async-throttler/injectAsyncThrottledCallback.d.cts +0 -1
  37. package/dist/async-throttler/injectAsyncThrottledCallback.d.ts +0 -1
  38. package/dist/async-throttler/injectAsyncThrottledCallback.js.map +1 -1
  39. package/dist/async-throttler/injectAsyncThrottler.cjs.map +1 -1
  40. package/dist/async-throttler/injectAsyncThrottler.d.cts +0 -1
  41. package/dist/async-throttler/injectAsyncThrottler.d.ts +0 -1
  42. package/dist/async-throttler/injectAsyncThrottler.js.map +1 -1
  43. package/dist/batcher/injectBatchedCallback.cjs.map +1 -1
  44. package/dist/batcher/injectBatchedCallback.d.cts +0 -1
  45. package/dist/batcher/injectBatchedCallback.d.ts +0 -1
  46. package/dist/batcher/injectBatchedCallback.js.map +1 -1
  47. package/dist/batcher/injectBatcher.cjs.map +1 -1
  48. package/dist/batcher/injectBatcher.d.cts +0 -1
  49. package/dist/batcher/injectBatcher.d.ts +0 -1
  50. package/dist/batcher/injectBatcher.js.map +1 -1
  51. package/dist/debouncer/injectDebouncedCallback.cjs.map +1 -1
  52. package/dist/debouncer/injectDebouncedCallback.d.cts +0 -1
  53. package/dist/debouncer/injectDebouncedCallback.d.ts +0 -1
  54. package/dist/debouncer/injectDebouncedCallback.js.map +1 -1
  55. package/dist/debouncer/injectDebouncedSignal.cjs.map +1 -1
  56. package/dist/debouncer/injectDebouncedSignal.d.cts +0 -1
  57. package/dist/debouncer/injectDebouncedSignal.d.ts +0 -1
  58. package/dist/debouncer/injectDebouncedSignal.js.map +1 -1
  59. package/dist/debouncer/injectDebouncedValue.cjs.map +1 -1
  60. package/dist/debouncer/injectDebouncedValue.d.cts +0 -1
  61. package/dist/debouncer/injectDebouncedValue.d.ts +0 -1
  62. package/dist/debouncer/injectDebouncedValue.js.map +1 -1
  63. package/dist/debouncer/injectDebouncer.cjs.map +1 -1
  64. package/dist/debouncer/injectDebouncer.d.cts +0 -1
  65. package/dist/debouncer/injectDebouncer.d.ts +0 -1
  66. package/dist/debouncer/injectDebouncer.js.map +1 -1
  67. package/dist/provider/pacer-context.cjs.map +1 -1
  68. package/dist/provider/pacer-context.d.cts +0 -1
  69. package/dist/provider/pacer-context.d.ts +0 -1
  70. package/dist/provider/pacer-context.js.map +1 -1
  71. package/dist/provider/pacer-provider.cjs.map +1 -1
  72. package/dist/provider/pacer-provider.d.cts +0 -1
  73. package/dist/provider/pacer-provider.d.ts +0 -1
  74. package/dist/provider/pacer-provider.js.map +1 -1
  75. package/dist/queuer/injectQueuedSignal.cjs.map +1 -1
  76. package/dist/queuer/injectQueuedSignal.d.cts +0 -1
  77. package/dist/queuer/injectQueuedSignal.d.ts +0 -1
  78. package/dist/queuer/injectQueuedSignal.js.map +1 -1
  79. package/dist/queuer/injectQueuedValue.cjs.map +1 -1
  80. package/dist/queuer/injectQueuedValue.d.cts +0 -1
  81. package/dist/queuer/injectQueuedValue.d.ts +0 -1
  82. package/dist/queuer/injectQueuedValue.js.map +1 -1
  83. package/dist/queuer/injectQueuer.cjs.map +1 -1
  84. package/dist/queuer/injectQueuer.d.cts +0 -1
  85. package/dist/queuer/injectQueuer.d.ts +0 -1
  86. package/dist/queuer/injectQueuer.js.map +1 -1
  87. package/dist/rate-limiter/injectRateLimitedCallback.cjs.map +1 -1
  88. package/dist/rate-limiter/injectRateLimitedCallback.d.cts +0 -1
  89. package/dist/rate-limiter/injectRateLimitedCallback.d.ts +0 -1
  90. package/dist/rate-limiter/injectRateLimitedCallback.js.map +1 -1
  91. package/dist/rate-limiter/injectRateLimitedSignal.cjs.map +1 -1
  92. package/dist/rate-limiter/injectRateLimitedSignal.d.cts +0 -1
  93. package/dist/rate-limiter/injectRateLimitedSignal.d.ts +0 -1
  94. package/dist/rate-limiter/injectRateLimitedSignal.js.map +1 -1
  95. package/dist/rate-limiter/injectRateLimitedValue.cjs.map +1 -1
  96. package/dist/rate-limiter/injectRateLimitedValue.d.cts +0 -1
  97. package/dist/rate-limiter/injectRateLimitedValue.d.ts +0 -1
  98. package/dist/rate-limiter/injectRateLimitedValue.js.map +1 -1
  99. package/dist/rate-limiter/injectRateLimiter.cjs.map +1 -1
  100. package/dist/rate-limiter/injectRateLimiter.d.cts +0 -1
  101. package/dist/rate-limiter/injectRateLimiter.d.ts +0 -1
  102. package/dist/rate-limiter/injectRateLimiter.js.map +1 -1
  103. package/dist/throttler/injectThrottledCallback.cjs.map +1 -1
  104. package/dist/throttler/injectThrottledCallback.d.cts +0 -1
  105. package/dist/throttler/injectThrottledCallback.d.ts +0 -1
  106. package/dist/throttler/injectThrottledCallback.js.map +1 -1
  107. package/dist/throttler/injectThrottledSignal.cjs.map +1 -1
  108. package/dist/throttler/injectThrottledSignal.d.cts +0 -1
  109. package/dist/throttler/injectThrottledSignal.d.ts +0 -1
  110. package/dist/throttler/injectThrottledSignal.js.map +1 -1
  111. package/dist/throttler/injectThrottledValue.cjs.map +1 -1
  112. package/dist/throttler/injectThrottledValue.d.cts +0 -1
  113. package/dist/throttler/injectThrottledValue.d.ts +0 -1
  114. package/dist/throttler/injectThrottledValue.js.map +1 -1
  115. package/dist/throttler/injectThrottler.cjs.map +1 -1
  116. package/dist/throttler/injectThrottler.d.cts +0 -1
  117. package/dist/throttler/injectThrottler.d.ts +0 -1
  118. package/dist/throttler/injectThrottler.js.map +1 -1
  119. package/dist/types/index.cjs +0 -1
  120. package/dist/utils/index.cjs +0 -1
  121. package/package.json +5 -5
  122. package/src/debouncer/injectDebouncedValue.ts +1 -2
  123. package/src/queuer/injectQueuedValue.ts +2 -4
  124. package/src/rate-limiter/injectRateLimitedValue.ts +1 -2
  125. package/src/throttler/injectThrottledValue.ts +1 -2
@@ -1,6 +1,5 @@
1
1
  import { AsyncThrottlerOptions } from "@tanstack/pacer/async-throttler";
2
2
  import { AnyAsyncFunction } from "@tanstack/pacer/types";
3
-
4
3
  //#region src/async-throttler/injectAsyncThrottledCallback.d.ts
5
4
  /**
6
5
  * An Angular function that creates an async throttled version of a callback function.
@@ -1 +1 @@
1
- {"version":3,"file":"injectAsyncThrottledCallback.js","names":[],"sources":["../../src/async-throttler/injectAsyncThrottledCallback.ts"],"sourcesContent":["import { injectAsyncThrottler } from './injectAsyncThrottler'\nimport type { AsyncThrottlerOptions } from '@tanstack/pacer/async-throttler'\nimport type { AnyAsyncFunction } from '@tanstack/pacer/types'\n\n/**\n * An Angular function that creates an async throttled version of a callback function.\n * This function is essentially a wrapper around `injectAsyncThrottler` that provides\n * a simplified API for basic async throttling needs.\n *\n * The throttled function will execute at most once within the specified wait time.\n *\n * This function provides a simpler API compared to `injectAsyncThrottler`, making it ideal for basic\n * async throttling needs. However, it does not expose the underlying AsyncThrottler 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 `injectAsyncThrottler` function instead.\n *\n * @example\n * ```ts\n * // Throttle an async update handler\n * const handleUpdate = injectAsyncThrottledCallback(\n * async (data: Data) => {\n * const response = await fetch('/api/update', {\n * method: 'POST',\n * body: JSON.stringify(data)\n * });\n * return response.json();\n * },\n * { wait: 1000 }\n * );\n *\n * // Use in an event handler\n * const result = await handleUpdate(updateData);\n * ```\n */\nexport function injectAsyncThrottledCallback<TFn extends AnyAsyncFunction>(\n fn: TFn,\n options: AsyncThrottlerOptions<TFn>,\n): (...args: Parameters<TFn>) => Promise<Awaited<ReturnType<TFn>> | undefined> {\n const throttler = injectAsyncThrottler(fn, options)\n return async (...args: Parameters<TFn>) => {\n const result = await throttler.maybeExecute(...args)\n return result !== undefined ? await result : undefined\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,SAAgB,6BACd,IACA,SAC6E;CAC7E,MAAM,YAAY,qBAAqB,IAAI,QAAQ;AACnD,QAAO,OAAO,GAAG,SAA0B;EACzC,MAAM,SAAS,MAAM,UAAU,aAAa,GAAG,KAAK;AACpD,SAAO,WAAW,SAAY,MAAM,SAAS"}
1
+ {"version":3,"file":"injectAsyncThrottledCallback.js","names":[],"sources":["../../src/async-throttler/injectAsyncThrottledCallback.ts"],"sourcesContent":["import { injectAsyncThrottler } from './injectAsyncThrottler'\nimport type { AsyncThrottlerOptions } from '@tanstack/pacer/async-throttler'\nimport type { AnyAsyncFunction } from '@tanstack/pacer/types'\n\n/**\n * An Angular function that creates an async throttled version of a callback function.\n * This function is essentially a wrapper around `injectAsyncThrottler` that provides\n * a simplified API for basic async throttling needs.\n *\n * The throttled function will execute at most once within the specified wait time.\n *\n * This function provides a simpler API compared to `injectAsyncThrottler`, making it ideal for basic\n * async throttling needs. However, it does not expose the underlying AsyncThrottler 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 `injectAsyncThrottler` function instead.\n *\n * @example\n * ```ts\n * // Throttle an async update handler\n * const handleUpdate = injectAsyncThrottledCallback(\n * async (data: Data) => {\n * const response = await fetch('/api/update', {\n * method: 'POST',\n * body: JSON.stringify(data)\n * });\n * return response.json();\n * },\n * { wait: 1000 }\n * );\n *\n * // Use in an event handler\n * const result = await handleUpdate(updateData);\n * ```\n */\nexport function injectAsyncThrottledCallback<TFn extends AnyAsyncFunction>(\n fn: TFn,\n options: AsyncThrottlerOptions<TFn>,\n): (...args: Parameters<TFn>) => Promise<Awaited<ReturnType<TFn>> | undefined> {\n const throttler = injectAsyncThrottler(fn, options)\n return async (...args: Parameters<TFn>) => {\n const result = await throttler.maybeExecute(...args)\n return result !== undefined ? await result : undefined\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,SAAgB,6BACd,IACA,SAC6E;CAC7E,MAAM,YAAY,qBAAqB,IAAI,OAAO;CAClD,OAAO,OAAO,GAAG,SAA0B;EACzC,MAAM,SAAS,MAAM,UAAU,aAAa,GAAG,IAAI;EACnD,OAAO,WAAW,SAAY,MAAM,SAAS;CAC/C;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"injectAsyncThrottler.cjs","names":["injectPacerOptions","AsyncThrottler","DestroyRef"],"sources":["../../src/async-throttler/injectAsyncThrottler.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { AsyncThrottler } from '@tanstack/pacer/async-throttler'\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 AsyncThrottlerOptions,\n AsyncThrottlerState,\n} from '@tanstack/pacer/async-throttler'\n\nexport interface AngularAsyncThrottlerOptions<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n> extends AsyncThrottlerOptions<TFn> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the throttler 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?: (throttler: AngularAsyncThrottler<TFn, TSelected>) => void\n}\n\nexport interface AngularAsyncThrottler<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n> extends Omit<AsyncThrottler<TFn>, 'store'> {\n /**\n * Reactive state signal that will be updated when the async throttler state changes\n *\n * Use this instead of `throttler.store.state`\n */\n readonly state: Signal<Readonly<TSelected>>\n /**\n * @deprecated Use `throttler.state` instead of `throttler.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<AsyncThrottlerState<TFn>>>\n}\n\n/**\n * An Angular function that creates and manages an AsyncThrottler instance.\n *\n * This is a lower-level function that provides direct access to the AsyncThrottler's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * This function provides async throttling functionality with promise support, error handling,\n * retry capabilities, and abort support.\n *\n * The throttler will execute the function at most once within the specified wait time.\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 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 throttler = injectAsyncThrottler(fn, {\n * wait: 1000,\n * onUnmount: (t) => t.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 throttler = injectAsyncThrottler(\n * async (data: Data) => {\n * const response = await fetch('/api/update', {\n * method: 'POST',\n * body: JSON.stringify(data)\n * });\n * return response.json();\n * },\n * { wait: 1000 }\n * );\n *\n * // In an event handler\n * const handleUpdate = async (data: Data) => {\n * const result = await throttler.maybeExecute(data);\n * console.log('Update result:', result);\n * };\n * ```\n */\nexport function injectAsyncThrottler<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n>(\n fn: TFn,\n options: AngularAsyncThrottlerOptions<TFn, TSelected>,\n selector: (state: AsyncThrottlerState<TFn>) => TSelected = () =>\n ({}) as TSelected,\n): AngularAsyncThrottler<TFn, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().asyncThrottler,\n ...options,\n } as AngularAsyncThrottlerOptions<TFn, TSelected>\n\n const throttler = new AsyncThrottler<TFn>(fn, mergedOptions)\n const state = injectSelector(throttler.store, selector)\n\n const result = {\n ...throttler,\n state,\n } as AngularAsyncThrottler<TFn, TSelected>\n\n const destroyRef = inject(DestroyRef, { optional: true })\n destroyRef?.onDestroy(() => {\n if (mergedOptions.onUnmount) {\n mergedOptions.onUnmount(result)\n } else {\n throttler.cancel()\n throttler.abort()\n }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiGA,SAAgB,qBAId,IACA,SACA,kBACG,EAAE,GACkC;CACvC,MAAM,gBAAgB;EACpB,GAAGA,0CAAoB,CAAC;EACxB,GAAG;EACJ;CAED,MAAM,YAAY,IAAIC,+CAAoB,IAAI,cAAc;CAC5D,MAAM,oDAAuB,UAAU,OAAO,SAAS;CAEvD,MAAM,SAAS;EACb,GAAG;EACH;EACD;AAGD,2BAD0BC,0BAAY,EAAE,UAAU,MAAM,CAAC,EAC7C,gBAAgB;AAC1B,MAAI,cAAc,UAChB,eAAc,UAAU,OAAO;OAC1B;AACL,aAAU,QAAQ;AAClB,aAAU,OAAO;;GAEnB;AAEF,QAAO"}
1
+ {"version":3,"file":"injectAsyncThrottler.cjs","names":["injectPacerOptions","AsyncThrottler","injectSelector","inject","DestroyRef"],"sources":["../../src/async-throttler/injectAsyncThrottler.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { AsyncThrottler } from '@tanstack/pacer/async-throttler'\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 AsyncThrottlerOptions,\n AsyncThrottlerState,\n} from '@tanstack/pacer/async-throttler'\n\nexport interface AngularAsyncThrottlerOptions<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n> extends AsyncThrottlerOptions<TFn> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the throttler 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?: (throttler: AngularAsyncThrottler<TFn, TSelected>) => void\n}\n\nexport interface AngularAsyncThrottler<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n> extends Omit<AsyncThrottler<TFn>, 'store'> {\n /**\n * Reactive state signal that will be updated when the async throttler state changes\n *\n * Use this instead of `throttler.store.state`\n */\n readonly state: Signal<Readonly<TSelected>>\n /**\n * @deprecated Use `throttler.state` instead of `throttler.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<AsyncThrottlerState<TFn>>>\n}\n\n/**\n * An Angular function that creates and manages an AsyncThrottler instance.\n *\n * This is a lower-level function that provides direct access to the AsyncThrottler's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * This function provides async throttling functionality with promise support, error handling,\n * retry capabilities, and abort support.\n *\n * The throttler will execute the function at most once within the specified wait time.\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 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 throttler = injectAsyncThrottler(fn, {\n * wait: 1000,\n * onUnmount: (t) => t.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 throttler = injectAsyncThrottler(\n * async (data: Data) => {\n * const response = await fetch('/api/update', {\n * method: 'POST',\n * body: JSON.stringify(data)\n * });\n * return response.json();\n * },\n * { wait: 1000 }\n * );\n *\n * // In an event handler\n * const handleUpdate = async (data: Data) => {\n * const result = await throttler.maybeExecute(data);\n * console.log('Update result:', result);\n * };\n * ```\n */\nexport function injectAsyncThrottler<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n>(\n fn: TFn,\n options: AngularAsyncThrottlerOptions<TFn, TSelected>,\n selector: (state: AsyncThrottlerState<TFn>) => TSelected = () =>\n ({}) as TSelected,\n): AngularAsyncThrottler<TFn, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().asyncThrottler,\n ...options,\n } as AngularAsyncThrottlerOptions<TFn, TSelected>\n\n const throttler = new AsyncThrottler<TFn>(fn, mergedOptions)\n const state = injectSelector(throttler.store, selector)\n\n const result = {\n ...throttler,\n state,\n } as AngularAsyncThrottler<TFn, TSelected>\n\n const destroyRef = inject(DestroyRef, { optional: true })\n destroyRef?.onDestroy(() => {\n if (mergedOptions.onUnmount) {\n mergedOptions.onUnmount(result)\n } else {\n throttler.cancel()\n throttler.abort()\n }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiGA,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"}
@@ -2,7 +2,6 @@ import { Signal } from "@angular/core";
2
2
  import { Store } from "@tanstack/angular-store";
3
3
  import { AnyAsyncFunction } from "@tanstack/pacer/types";
4
4
  import { AsyncThrottler, AsyncThrottlerOptions, AsyncThrottlerState } from "@tanstack/pacer/async-throttler";
5
-
6
5
  //#region src/async-throttler/injectAsyncThrottler.d.ts
7
6
  interface AngularAsyncThrottlerOptions<TFn extends AnyAsyncFunction, TSelected = {}> extends AsyncThrottlerOptions<TFn> {
8
7
  /**
@@ -2,7 +2,6 @@ import { Signal } from "@angular/core";
2
2
  import { Store } from "@tanstack/angular-store";
3
3
  import { AsyncThrottler, AsyncThrottlerOptions, AsyncThrottlerState } from "@tanstack/pacer/async-throttler";
4
4
  import { AnyAsyncFunction } from "@tanstack/pacer/types";
5
-
6
5
  //#region src/async-throttler/injectAsyncThrottler.d.ts
7
6
  interface AngularAsyncThrottlerOptions<TFn extends AnyAsyncFunction, TSelected = {}> extends AsyncThrottlerOptions<TFn> {
8
7
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"injectAsyncThrottler.js","names":[],"sources":["../../src/async-throttler/injectAsyncThrottler.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { AsyncThrottler } from '@tanstack/pacer/async-throttler'\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 AsyncThrottlerOptions,\n AsyncThrottlerState,\n} from '@tanstack/pacer/async-throttler'\n\nexport interface AngularAsyncThrottlerOptions<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n> extends AsyncThrottlerOptions<TFn> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the throttler 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?: (throttler: AngularAsyncThrottler<TFn, TSelected>) => void\n}\n\nexport interface AngularAsyncThrottler<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n> extends Omit<AsyncThrottler<TFn>, 'store'> {\n /**\n * Reactive state signal that will be updated when the async throttler state changes\n *\n * Use this instead of `throttler.store.state`\n */\n readonly state: Signal<Readonly<TSelected>>\n /**\n * @deprecated Use `throttler.state` instead of `throttler.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<AsyncThrottlerState<TFn>>>\n}\n\n/**\n * An Angular function that creates and manages an AsyncThrottler instance.\n *\n * This is a lower-level function that provides direct access to the AsyncThrottler's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * This function provides async throttling functionality with promise support, error handling,\n * retry capabilities, and abort support.\n *\n * The throttler will execute the function at most once within the specified wait time.\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 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 throttler = injectAsyncThrottler(fn, {\n * wait: 1000,\n * onUnmount: (t) => t.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 throttler = injectAsyncThrottler(\n * async (data: Data) => {\n * const response = await fetch('/api/update', {\n * method: 'POST',\n * body: JSON.stringify(data)\n * });\n * return response.json();\n * },\n * { wait: 1000 }\n * );\n *\n * // In an event handler\n * const handleUpdate = async (data: Data) => {\n * const result = await throttler.maybeExecute(data);\n * console.log('Update result:', result);\n * };\n * ```\n */\nexport function injectAsyncThrottler<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n>(\n fn: TFn,\n options: AngularAsyncThrottlerOptions<TFn, TSelected>,\n selector: (state: AsyncThrottlerState<TFn>) => TSelected = () =>\n ({}) as TSelected,\n): AngularAsyncThrottler<TFn, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().asyncThrottler,\n ...options,\n } as AngularAsyncThrottlerOptions<TFn, TSelected>\n\n const throttler = new AsyncThrottler<TFn>(fn, mergedOptions)\n const state = injectSelector(throttler.store, selector)\n\n const result = {\n ...throttler,\n state,\n } as AngularAsyncThrottler<TFn, TSelected>\n\n const destroyRef = inject(DestroyRef, { optional: true })\n destroyRef?.onDestroy(() => {\n if (mergedOptions.onUnmount) {\n mergedOptions.onUnmount(result)\n } else {\n throttler.cancel()\n throttler.abort()\n }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiGA,SAAgB,qBAId,IACA,SACA,kBACG,EAAE,GACkC;CACvC,MAAM,gBAAgB;EACpB,GAAG,oBAAoB,CAAC;EACxB,GAAG;EACJ;CAED,MAAM,YAAY,IAAI,eAAoB,IAAI,cAAc;CAC5D,MAAM,QAAQ,eAAe,UAAU,OAAO,SAAS;CAEvD,MAAM,SAAS;EACb,GAAG;EACH;EACD;AAGD,CADmB,OAAO,YAAY,EAAE,UAAU,MAAM,CAAC,EAC7C,gBAAgB;AAC1B,MAAI,cAAc,UAChB,eAAc,UAAU,OAAO;OAC1B;AACL,aAAU,QAAQ;AAClB,aAAU,OAAO;;GAEnB;AAEF,QAAO"}
1
+ {"version":3,"file":"injectAsyncThrottler.js","names":[],"sources":["../../src/async-throttler/injectAsyncThrottler.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { AsyncThrottler } from '@tanstack/pacer/async-throttler'\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 AsyncThrottlerOptions,\n AsyncThrottlerState,\n} from '@tanstack/pacer/async-throttler'\n\nexport interface AngularAsyncThrottlerOptions<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n> extends AsyncThrottlerOptions<TFn> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the throttler 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?: (throttler: AngularAsyncThrottler<TFn, TSelected>) => void\n}\n\nexport interface AngularAsyncThrottler<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n> extends Omit<AsyncThrottler<TFn>, 'store'> {\n /**\n * Reactive state signal that will be updated when the async throttler state changes\n *\n * Use this instead of `throttler.store.state`\n */\n readonly state: Signal<Readonly<TSelected>>\n /**\n * @deprecated Use `throttler.state` instead of `throttler.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<AsyncThrottlerState<TFn>>>\n}\n\n/**\n * An Angular function that creates and manages an AsyncThrottler instance.\n *\n * This is a lower-level function that provides direct access to the AsyncThrottler's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * This function provides async throttling functionality with promise support, error handling,\n * retry capabilities, and abort support.\n *\n * The throttler will execute the function at most once within the specified wait time.\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 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 throttler = injectAsyncThrottler(fn, {\n * wait: 1000,\n * onUnmount: (t) => t.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 throttler = injectAsyncThrottler(\n * async (data: Data) => {\n * const response = await fetch('/api/update', {\n * method: 'POST',\n * body: JSON.stringify(data)\n * });\n * return response.json();\n * },\n * { wait: 1000 }\n * );\n *\n * // In an event handler\n * const handleUpdate = async (data: Data) => {\n * const result = await throttler.maybeExecute(data);\n * console.log('Update result:', result);\n * };\n * ```\n */\nexport function injectAsyncThrottler<\n TFn extends AnyAsyncFunction,\n TSelected = {},\n>(\n fn: TFn,\n options: AngularAsyncThrottlerOptions<TFn, TSelected>,\n selector: (state: AsyncThrottlerState<TFn>) => TSelected = () =>\n ({}) as TSelected,\n): AngularAsyncThrottler<TFn, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().asyncThrottler,\n ...options,\n } as AngularAsyncThrottlerOptions<TFn, TSelected>\n\n const throttler = new AsyncThrottler<TFn>(fn, mergedOptions)\n const state = injectSelector(throttler.store, selector)\n\n const result = {\n ...throttler,\n state,\n } as AngularAsyncThrottler<TFn, TSelected>\n\n const destroyRef = inject(DestroyRef, { optional: true })\n destroyRef?.onDestroy(() => {\n if (mergedOptions.onUnmount) {\n mergedOptions.onUnmount(result)\n } else {\n throttler.cancel()\n throttler.abort()\n }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiGA,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 +1 @@
1
- {"version":3,"file":"injectBatchedCallback.cjs","names":["injectBatcher"],"sources":["../../src/batcher/injectBatchedCallback.ts"],"sourcesContent":["import { injectBatcher } from './injectBatcher'\nimport type { BatcherOptions } from '@tanstack/pacer/batcher'\n\n/**\n * An Angular function that creates a batched version of a callback function.\n * This function is essentially a wrapper around `injectBatcher` that provides\n * a simplified API for basic batching needs.\n *\n * The batched function will collect items and process them in batches based on\n * the configured conditions (maxSize, wait time, etc.).\n *\n * This function provides a simpler API compared to `injectBatcher`, making it ideal for basic\n * batching needs. However, it does not expose the underlying Batcher instance.\n *\n * For advanced usage requiring features like:\n * - Manual flushing\n * - Access to batch state\n * - State tracking\n *\n * Consider using the `injectBatcher` function instead.\n *\n * @example\n * ```ts\n * // Batch API calls\n * const batchApiCall = injectBatchedCallback(\n * (items) => {\n * return fetch('/api/batch', {\n * method: 'POST',\n * body: JSON.stringify(items)\n * });\n * },\n * { maxSize: 10, wait: 1000 }\n * );\n *\n * // Items will be batched and sent together\n * batchApiCall('item1');\n * batchApiCall('item2');\n * ```\n */\nexport function injectBatchedCallback<TValue>(\n fn: (items: Array<TValue>) => void,\n options: BatcherOptions<TValue>,\n): (item: TValue) => void {\n const batcher = injectBatcher(fn, options)\n return (item: TValue) => batcher.addItem(item)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,sBACd,IACA,SACwB;CACxB,MAAM,UAAUA,oCAAc,IAAI,QAAQ;AAC1C,SAAQ,SAAiB,QAAQ,QAAQ,KAAK"}
1
+ {"version":3,"file":"injectBatchedCallback.cjs","names":["injectBatcher"],"sources":["../../src/batcher/injectBatchedCallback.ts"],"sourcesContent":["import { injectBatcher } from './injectBatcher'\nimport type { BatcherOptions } from '@tanstack/pacer/batcher'\n\n/**\n * An Angular function that creates a batched version of a callback function.\n * This function is essentially a wrapper around `injectBatcher` that provides\n * a simplified API for basic batching needs.\n *\n * The batched function will collect items and process them in batches based on\n * the configured conditions (maxSize, wait time, etc.).\n *\n * This function provides a simpler API compared to `injectBatcher`, making it ideal for basic\n * batching needs. However, it does not expose the underlying Batcher instance.\n *\n * For advanced usage requiring features like:\n * - Manual flushing\n * - Access to batch state\n * - State tracking\n *\n * Consider using the `injectBatcher` function instead.\n *\n * @example\n * ```ts\n * // Batch API calls\n * const batchApiCall = injectBatchedCallback(\n * (items) => {\n * return fetch('/api/batch', {\n * method: 'POST',\n * body: JSON.stringify(items)\n * });\n * },\n * { maxSize: 10, wait: 1000 }\n * );\n *\n * // Items will be batched and sent together\n * batchApiCall('item1');\n * batchApiCall('item2');\n * ```\n */\nexport function injectBatchedCallback<TValue>(\n fn: (items: Array<TValue>) => void,\n options: BatcherOptions<TValue>,\n): (item: TValue) => void {\n const batcher = injectBatcher(fn, options)\n return (item: TValue) => batcher.addItem(item)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,sBACd,IACA,SACwB;CACxB,MAAM,UAAUA,oCAAc,IAAI,OAAO;CACzC,QAAQ,SAAiB,QAAQ,QAAQ,IAAI;AAC/C"}
@@ -1,5 +1,4 @@
1
1
  import { BatcherOptions } from "@tanstack/pacer/batcher";
2
-
3
2
  //#region src/batcher/injectBatchedCallback.d.ts
4
3
  /**
5
4
  * An Angular function that creates a batched version of a callback function.
@@ -1,5 +1,4 @@
1
1
  import { BatcherOptions } from "@tanstack/pacer/batcher";
2
-
3
2
  //#region src/batcher/injectBatchedCallback.d.ts
4
3
  /**
5
4
  * An Angular function that creates a batched version of a callback function.
@@ -1 +1 @@
1
- {"version":3,"file":"injectBatchedCallback.js","names":[],"sources":["../../src/batcher/injectBatchedCallback.ts"],"sourcesContent":["import { injectBatcher } from './injectBatcher'\nimport type { BatcherOptions } from '@tanstack/pacer/batcher'\n\n/**\n * An Angular function that creates a batched version of a callback function.\n * This function is essentially a wrapper around `injectBatcher` that provides\n * a simplified API for basic batching needs.\n *\n * The batched function will collect items and process them in batches based on\n * the configured conditions (maxSize, wait time, etc.).\n *\n * This function provides a simpler API compared to `injectBatcher`, making it ideal for basic\n * batching needs. However, it does not expose the underlying Batcher instance.\n *\n * For advanced usage requiring features like:\n * - Manual flushing\n * - Access to batch state\n * - State tracking\n *\n * Consider using the `injectBatcher` function instead.\n *\n * @example\n * ```ts\n * // Batch API calls\n * const batchApiCall = injectBatchedCallback(\n * (items) => {\n * return fetch('/api/batch', {\n * method: 'POST',\n * body: JSON.stringify(items)\n * });\n * },\n * { maxSize: 10, wait: 1000 }\n * );\n *\n * // Items will be batched and sent together\n * batchApiCall('item1');\n * batchApiCall('item2');\n * ```\n */\nexport function injectBatchedCallback<TValue>(\n fn: (items: Array<TValue>) => void,\n options: BatcherOptions<TValue>,\n): (item: TValue) => void {\n const batcher = injectBatcher(fn, options)\n return (item: TValue) => batcher.addItem(item)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,sBACd,IACA,SACwB;CACxB,MAAM,UAAU,cAAc,IAAI,QAAQ;AAC1C,SAAQ,SAAiB,QAAQ,QAAQ,KAAK"}
1
+ {"version":3,"file":"injectBatchedCallback.js","names":[],"sources":["../../src/batcher/injectBatchedCallback.ts"],"sourcesContent":["import { injectBatcher } from './injectBatcher'\nimport type { BatcherOptions } from '@tanstack/pacer/batcher'\n\n/**\n * An Angular function that creates a batched version of a callback function.\n * This function is essentially a wrapper around `injectBatcher` that provides\n * a simplified API for basic batching needs.\n *\n * The batched function will collect items and process them in batches based on\n * the configured conditions (maxSize, wait time, etc.).\n *\n * This function provides a simpler API compared to `injectBatcher`, making it ideal for basic\n * batching needs. However, it does not expose the underlying Batcher instance.\n *\n * For advanced usage requiring features like:\n * - Manual flushing\n * - Access to batch state\n * - State tracking\n *\n * Consider using the `injectBatcher` function instead.\n *\n * @example\n * ```ts\n * // Batch API calls\n * const batchApiCall = injectBatchedCallback(\n * (items) => {\n * return fetch('/api/batch', {\n * method: 'POST',\n * body: JSON.stringify(items)\n * });\n * },\n * { maxSize: 10, wait: 1000 }\n * );\n *\n * // Items will be batched and sent together\n * batchApiCall('item1');\n * batchApiCall('item2');\n * ```\n */\nexport function injectBatchedCallback<TValue>(\n fn: (items: Array<TValue>) => void,\n options: BatcherOptions<TValue>,\n): (item: TValue) => void {\n const batcher = injectBatcher(fn, options)\n return (item: TValue) => batcher.addItem(item)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,sBACd,IACA,SACwB;CACxB,MAAM,UAAU,cAAc,IAAI,OAAO;CACzC,QAAQ,SAAiB,QAAQ,QAAQ,IAAI;AAC/C"}
@@ -1 +1 @@
1
- {"version":3,"file":"injectBatcher.cjs","names":["injectPacerOptions","Batcher","DestroyRef"],"sources":["../../src/batcher/injectBatcher.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { Batcher } from '@tanstack/pacer/batcher'\nimport { injectPacerOptions } from '../provider/pacer-context'\nimport type { Signal } from '@angular/core'\nimport type { Store } from '@tanstack/angular-store'\nimport type { BatcherOptions, BatcherState } from '@tanstack/pacer/batcher'\n\nexport interface AngularBatcherOptions<\n TValue,\n TSelected = {},\n> extends BatcherOptions<TValue> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the batcher instance.\n * When provided, replaces the default cleanup (cancel); use it to call flush(), cancel(), add logging, etc.\n */\n onUnmount?: (batcher: AngularBatcher<TValue, TSelected>) => void\n}\n\nexport interface AngularBatcher<TValue, TSelected = {}> extends Omit<\n Batcher<TValue>,\n 'store'\n> {\n /**\n * Reactive state signal that will be updated when the 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<BatcherState<TValue>>>\n}\n\n/**\n * An Angular function that creates and manages a Batcher instance.\n *\n * This is a lower-level function that provides direct access to the Batcher's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * The Batcher collects items and processes them in batches based on configurable conditions:\n * - Maximum batch size\n * - Time-based batching (process after X milliseconds)\n * - Custom batch processing logic via getShouldExecute\n *\n * ## State Management and Selector\n *\n * The 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 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 = injectBatcher(fn, {\n * maxSize: 5,\n * onUnmount: (b) => b.flush()\n * });\n * ```\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const batcher = injectBatcher(\n * (items) => console.log('Processing batch:', items),\n * { maxSize: 5, wait: 2000 }\n * );\n *\n * // Add items\n * batcher.addItem('task1');\n *\n * // Access the selected state\n * const { items, isPending } = batcher.state();\n * ```\n */\nexport function injectBatcher<TValue, TSelected = {}>(\n fn: (items: Array<TValue>) => void,\n options: AngularBatcherOptions<TValue, TSelected> = {},\n selector: (state: BatcherState<TValue>) => TSelected = () =>\n ({}) as TSelected,\n): AngularBatcher<TValue, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().batcher,\n ...options,\n } as AngularBatcherOptions<TValue, TSelected>\n\n const batcher = new Batcher<TValue>(fn, mergedOptions)\n const state = injectSelector(batcher.store, selector)\n\n const result = {\n ...batcher,\n state,\n } as AngularBatcher<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 }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,SAAgB,cACd,IACA,UAAoD,EAAE,EACtD,kBACG,EAAE,GAC8B;CACnC,MAAM,gBAAgB;EACpB,GAAGA,0CAAoB,CAAC;EACxB,GAAG;EACJ;CAED,MAAM,UAAU,IAAIC,gCAAgB,IAAI,cAAc;CACtD,MAAM,oDAAuB,QAAQ,OAAO,SAAS;CAErD,MAAM,SAAS;EACb,GAAG;EACH;EACD;AAGD,2BAD0BC,0BAAY,EAAE,UAAU,MAAM,CAAC,EAC7C,gBAAgB;AAC1B,MAAI,cAAc,UAChB,eAAc,UAAU,OAAO;MAE/B,SAAQ,QAAQ;GAElB;AAEF,QAAO"}
1
+ {"version":3,"file":"injectBatcher.cjs","names":["injectPacerOptions","Batcher","injectSelector","inject","DestroyRef"],"sources":["../../src/batcher/injectBatcher.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { Batcher } from '@tanstack/pacer/batcher'\nimport { injectPacerOptions } from '../provider/pacer-context'\nimport type { Signal } from '@angular/core'\nimport type { Store } from '@tanstack/angular-store'\nimport type { BatcherOptions, BatcherState } from '@tanstack/pacer/batcher'\n\nexport interface AngularBatcherOptions<\n TValue,\n TSelected = {},\n> extends BatcherOptions<TValue> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the batcher instance.\n * When provided, replaces the default cleanup (cancel); use it to call flush(), cancel(), add logging, etc.\n */\n onUnmount?: (batcher: AngularBatcher<TValue, TSelected>) => void\n}\n\nexport interface AngularBatcher<TValue, TSelected = {}> extends Omit<\n Batcher<TValue>,\n 'store'\n> {\n /**\n * Reactive state signal that will be updated when the 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<BatcherState<TValue>>>\n}\n\n/**\n * An Angular function that creates and manages a Batcher instance.\n *\n * This is a lower-level function that provides direct access to the Batcher's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * The Batcher collects items and processes them in batches based on configurable conditions:\n * - Maximum batch size\n * - Time-based batching (process after X milliseconds)\n * - Custom batch processing logic via getShouldExecute\n *\n * ## State Management and Selector\n *\n * The 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 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 = injectBatcher(fn, {\n * maxSize: 5,\n * onUnmount: (b) => b.flush()\n * });\n * ```\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const batcher = injectBatcher(\n * (items) => console.log('Processing batch:', items),\n * { maxSize: 5, wait: 2000 }\n * );\n *\n * // Add items\n * batcher.addItem('task1');\n *\n * // Access the selected state\n * const { items, isPending } = batcher.state();\n * ```\n */\nexport function injectBatcher<TValue, TSelected = {}>(\n fn: (items: Array<TValue>) => void,\n options: AngularBatcherOptions<TValue, TSelected> = {},\n selector: (state: BatcherState<TValue>) => TSelected = () =>\n ({}) as TSelected,\n): AngularBatcher<TValue, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().batcher,\n ...options,\n } as AngularBatcherOptions<TValue, TSelected>\n\n const batcher = new Batcher<TValue>(fn, mergedOptions)\n const state = injectSelector(batcher.store, selector)\n\n const result = {\n ...batcher,\n state,\n } as AngularBatcher<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 }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,SAAgB,cACd,IACA,UAAoD,CAAC,GACrD,kBACG,CAAC,IAC+B;CACnC,MAAM,gBAAgB;EACpB,GAAGA,yCAAmB,CAAC,CAAC;EACxB,GAAG;CACL;CAEA,MAAM,UAAU,IAAIC,gCAAgB,IAAI,aAAa;CACrD,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;OAE9B,QAAQ,OAAO;CAEnB,CAAC;CAED,OAAO;AACT"}
@@ -1,7 +1,6 @@
1
1
  import { Signal } from "@angular/core";
2
2
  import { Store } from "@tanstack/angular-store";
3
3
  import { Batcher, BatcherOptions, BatcherState } from "@tanstack/pacer/batcher";
4
-
5
4
  //#region src/batcher/injectBatcher.d.ts
6
5
  interface AngularBatcherOptions<TValue, TSelected = {}> extends BatcherOptions<TValue> {
7
6
  /**
@@ -1,7 +1,6 @@
1
1
  import { Signal } from "@angular/core";
2
2
  import { Store } from "@tanstack/angular-store";
3
3
  import { Batcher, BatcherOptions, BatcherState } from "@tanstack/pacer/batcher";
4
-
5
4
  //#region src/batcher/injectBatcher.d.ts
6
5
  interface AngularBatcherOptions<TValue, TSelected = {}> extends BatcherOptions<TValue> {
7
6
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"injectBatcher.js","names":[],"sources":["../../src/batcher/injectBatcher.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { Batcher } from '@tanstack/pacer/batcher'\nimport { injectPacerOptions } from '../provider/pacer-context'\nimport type { Signal } from '@angular/core'\nimport type { Store } from '@tanstack/angular-store'\nimport type { BatcherOptions, BatcherState } from '@tanstack/pacer/batcher'\n\nexport interface AngularBatcherOptions<\n TValue,\n TSelected = {},\n> extends BatcherOptions<TValue> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the batcher instance.\n * When provided, replaces the default cleanup (cancel); use it to call flush(), cancel(), add logging, etc.\n */\n onUnmount?: (batcher: AngularBatcher<TValue, TSelected>) => void\n}\n\nexport interface AngularBatcher<TValue, TSelected = {}> extends Omit<\n Batcher<TValue>,\n 'store'\n> {\n /**\n * Reactive state signal that will be updated when the 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<BatcherState<TValue>>>\n}\n\n/**\n * An Angular function that creates and manages a Batcher instance.\n *\n * This is a lower-level function that provides direct access to the Batcher's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * The Batcher collects items and processes them in batches based on configurable conditions:\n * - Maximum batch size\n * - Time-based batching (process after X milliseconds)\n * - Custom batch processing logic via getShouldExecute\n *\n * ## State Management and Selector\n *\n * The 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 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 = injectBatcher(fn, {\n * maxSize: 5,\n * onUnmount: (b) => b.flush()\n * });\n * ```\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const batcher = injectBatcher(\n * (items) => console.log('Processing batch:', items),\n * { maxSize: 5, wait: 2000 }\n * );\n *\n * // Add items\n * batcher.addItem('task1');\n *\n * // Access the selected state\n * const { items, isPending } = batcher.state();\n * ```\n */\nexport function injectBatcher<TValue, TSelected = {}>(\n fn: (items: Array<TValue>) => void,\n options: AngularBatcherOptions<TValue, TSelected> = {},\n selector: (state: BatcherState<TValue>) => TSelected = () =>\n ({}) as TSelected,\n): AngularBatcher<TValue, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().batcher,\n ...options,\n } as AngularBatcherOptions<TValue, TSelected>\n\n const batcher = new Batcher<TValue>(fn, mergedOptions)\n const state = injectSelector(batcher.store, selector)\n\n const result = {\n ...batcher,\n state,\n } as AngularBatcher<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 }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,SAAgB,cACd,IACA,UAAoD,EAAE,EACtD,kBACG,EAAE,GAC8B;CACnC,MAAM,gBAAgB;EACpB,GAAG,oBAAoB,CAAC;EACxB,GAAG;EACJ;CAED,MAAM,UAAU,IAAI,QAAgB,IAAI,cAAc;CACtD,MAAM,QAAQ,eAAe,QAAQ,OAAO,SAAS;CAErD,MAAM,SAAS;EACb,GAAG;EACH;EACD;AAGD,CADmB,OAAO,YAAY,EAAE,UAAU,MAAM,CAAC,EAC7C,gBAAgB;AAC1B,MAAI,cAAc,UAChB,eAAc,UAAU,OAAO;MAE/B,SAAQ,QAAQ;GAElB;AAEF,QAAO"}
1
+ {"version":3,"file":"injectBatcher.js","names":[],"sources":["../../src/batcher/injectBatcher.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { Batcher } from '@tanstack/pacer/batcher'\nimport { injectPacerOptions } from '../provider/pacer-context'\nimport type { Signal } from '@angular/core'\nimport type { Store } from '@tanstack/angular-store'\nimport type { BatcherOptions, BatcherState } from '@tanstack/pacer/batcher'\n\nexport interface AngularBatcherOptions<\n TValue,\n TSelected = {},\n> extends BatcherOptions<TValue> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the batcher instance.\n * When provided, replaces the default cleanup (cancel); use it to call flush(), cancel(), add logging, etc.\n */\n onUnmount?: (batcher: AngularBatcher<TValue, TSelected>) => void\n}\n\nexport interface AngularBatcher<TValue, TSelected = {}> extends Omit<\n Batcher<TValue>,\n 'store'\n> {\n /**\n * Reactive state signal that will be updated when the 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<BatcherState<TValue>>>\n}\n\n/**\n * An Angular function that creates and manages a Batcher instance.\n *\n * This is a lower-level function that provides direct access to the Batcher's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * The Batcher collects items and processes them in batches based on configurable conditions:\n * - Maximum batch size\n * - Time-based batching (process after X milliseconds)\n * - Custom batch processing logic via getShouldExecute\n *\n * ## State Management and Selector\n *\n * The 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 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 = injectBatcher(fn, {\n * maxSize: 5,\n * onUnmount: (b) => b.flush()\n * });\n * ```\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const batcher = injectBatcher(\n * (items) => console.log('Processing batch:', items),\n * { maxSize: 5, wait: 2000 }\n * );\n *\n * // Add items\n * batcher.addItem('task1');\n *\n * // Access the selected state\n * const { items, isPending } = batcher.state();\n * ```\n */\nexport function injectBatcher<TValue, TSelected = {}>(\n fn: (items: Array<TValue>) => void,\n options: AngularBatcherOptions<TValue, TSelected> = {},\n selector: (state: BatcherState<TValue>) => TSelected = () =>\n ({}) as TSelected,\n): AngularBatcher<TValue, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().batcher,\n ...options,\n } as AngularBatcherOptions<TValue, TSelected>\n\n const batcher = new Batcher<TValue>(fn, mergedOptions)\n const state = injectSelector(batcher.store, selector)\n\n const result = {\n ...batcher,\n state,\n } as AngularBatcher<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 }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,SAAgB,cACd,IACA,UAAoD,CAAC,GACrD,kBACG,CAAC,IAC+B;CACnC,MAAM,gBAAgB;EACpB,GAAG,mBAAmB,CAAC,CAAC;EACxB,GAAG;CACL;CAEA,MAAM,UAAU,IAAI,QAAgB,IAAI,aAAa;CACrD,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;OAE9B,QAAQ,OAAO;CAEnB,CAAC;CAED,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"injectDebouncedCallback.cjs","names":["injectDebouncer"],"sources":["../../src/debouncer/injectDebouncedCallback.ts"],"sourcesContent":["import { injectDebouncer } from './injectDebouncer'\nimport type { DebouncerOptions } from '@tanstack/pacer/debouncer'\nimport type { AnyFunction } from '@tanstack/pacer/types'\n\n/**\n * An Angular function that creates a debounced version of a callback function.\n * This function is essentially a wrapper around `injectDebouncer` that provides\n * a simplified API for basic debouncing needs.\n *\n * The debounced function will only execute after the specified wait time has elapsed\n * since its last invocation. If called again before the wait time expires, the timer\n * resets and starts waiting again.\n *\n * This function provides a simpler API compared to `injectDebouncer`, making it ideal for basic\n * debouncing needs. However, it does not expose the underlying Debouncer instance.\n *\n * For advanced usage requiring features like:\n * - Manual cancellation\n * - Access to execution counts\n * - State tracking\n *\n * Consider using the `injectDebouncer` function instead.\n *\n * @example\n * ```ts\n * // Debounce a search handler\n * const handleSearch = injectDebouncedCallback((query: string) => {\n * fetchSearchResults(query);\n * }, {\n * wait: 500 // Wait 500ms between executions\n * });\n *\n * // Use in an input\n * <input\n * type=\"search\"\n * (input)=\"handleSearch($event.target.value)\"\n * />\n * ```\n */\nexport function injectDebouncedCallback<TFn extends AnyFunction>(\n fn: TFn,\n options: DebouncerOptions<TFn>,\n): (...args: Parameters<TFn>) => void {\n const debouncer = injectDebouncer(fn, options)\n return (...args: Parameters<TFn>) => debouncer.maybeExecute(...args)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,wBACd,IACA,SACoC;CACpC,MAAM,YAAYA,wCAAgB,IAAI,QAAQ;AAC9C,SAAQ,GAAG,SAA0B,UAAU,aAAa,GAAG,KAAK"}
1
+ {"version":3,"file":"injectDebouncedCallback.cjs","names":["injectDebouncer"],"sources":["../../src/debouncer/injectDebouncedCallback.ts"],"sourcesContent":["import { injectDebouncer } from './injectDebouncer'\nimport type { DebouncerOptions } from '@tanstack/pacer/debouncer'\nimport type { AnyFunction } from '@tanstack/pacer/types'\n\n/**\n * An Angular function that creates a debounced version of a callback function.\n * This function is essentially a wrapper around `injectDebouncer` that provides\n * a simplified API for basic debouncing needs.\n *\n * The debounced function will only execute after the specified wait time has elapsed\n * since its last invocation. If called again before the wait time expires, the timer\n * resets and starts waiting again.\n *\n * This function provides a simpler API compared to `injectDebouncer`, making it ideal for basic\n * debouncing needs. However, it does not expose the underlying Debouncer instance.\n *\n * For advanced usage requiring features like:\n * - Manual cancellation\n * - Access to execution counts\n * - State tracking\n *\n * Consider using the `injectDebouncer` function instead.\n *\n * @example\n * ```ts\n * // Debounce a search handler\n * const handleSearch = injectDebouncedCallback((query: string) => {\n * fetchSearchResults(query);\n * }, {\n * wait: 500 // Wait 500ms between executions\n * });\n *\n * // Use in an input\n * <input\n * type=\"search\"\n * (input)=\"handleSearch($event.target.value)\"\n * />\n * ```\n */\nexport function injectDebouncedCallback<TFn extends AnyFunction>(\n fn: TFn,\n options: DebouncerOptions<TFn>,\n): (...args: Parameters<TFn>) => void {\n const debouncer = injectDebouncer(fn, options)\n return (...args: Parameters<TFn>) => debouncer.maybeExecute(...args)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,wBACd,IACA,SACoC;CACpC,MAAM,YAAYA,wCAAgB,IAAI,OAAO;CAC7C,QAAQ,GAAG,SAA0B,UAAU,aAAa,GAAG,IAAI;AACrE"}
@@ -1,6 +1,5 @@
1
1
  import { AnyFunction } from "@tanstack/pacer/types";
2
2
  import { DebouncerOptions } from "@tanstack/pacer/debouncer";
3
-
4
3
  //#region src/debouncer/injectDebouncedCallback.d.ts
5
4
  /**
6
5
  * An Angular function that creates a debounced version of a callback function.
@@ -1,6 +1,5 @@
1
1
  import { DebouncerOptions } from "@tanstack/pacer/debouncer";
2
2
  import { AnyFunction } from "@tanstack/pacer/types";
3
-
4
3
  //#region src/debouncer/injectDebouncedCallback.d.ts
5
4
  /**
6
5
  * An Angular function that creates a debounced version of a callback function.
@@ -1 +1 @@
1
- {"version":3,"file":"injectDebouncedCallback.js","names":[],"sources":["../../src/debouncer/injectDebouncedCallback.ts"],"sourcesContent":["import { injectDebouncer } from './injectDebouncer'\nimport type { DebouncerOptions } from '@tanstack/pacer/debouncer'\nimport type { AnyFunction } from '@tanstack/pacer/types'\n\n/**\n * An Angular function that creates a debounced version of a callback function.\n * This function is essentially a wrapper around `injectDebouncer` that provides\n * a simplified API for basic debouncing needs.\n *\n * The debounced function will only execute after the specified wait time has elapsed\n * since its last invocation. If called again before the wait time expires, the timer\n * resets and starts waiting again.\n *\n * This function provides a simpler API compared to `injectDebouncer`, making it ideal for basic\n * debouncing needs. However, it does not expose the underlying Debouncer instance.\n *\n * For advanced usage requiring features like:\n * - Manual cancellation\n * - Access to execution counts\n * - State tracking\n *\n * Consider using the `injectDebouncer` function instead.\n *\n * @example\n * ```ts\n * // Debounce a search handler\n * const handleSearch = injectDebouncedCallback((query: string) => {\n * fetchSearchResults(query);\n * }, {\n * wait: 500 // Wait 500ms between executions\n * });\n *\n * // Use in an input\n * <input\n * type=\"search\"\n * (input)=\"handleSearch($event.target.value)\"\n * />\n * ```\n */\nexport function injectDebouncedCallback<TFn extends AnyFunction>(\n fn: TFn,\n options: DebouncerOptions<TFn>,\n): (...args: Parameters<TFn>) => void {\n const debouncer = injectDebouncer(fn, options)\n return (...args: Parameters<TFn>) => debouncer.maybeExecute(...args)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,wBACd,IACA,SACoC;CACpC,MAAM,YAAY,gBAAgB,IAAI,QAAQ;AAC9C,SAAQ,GAAG,SAA0B,UAAU,aAAa,GAAG,KAAK"}
1
+ {"version":3,"file":"injectDebouncedCallback.js","names":[],"sources":["../../src/debouncer/injectDebouncedCallback.ts"],"sourcesContent":["import { injectDebouncer } from './injectDebouncer'\nimport type { DebouncerOptions } from '@tanstack/pacer/debouncer'\nimport type { AnyFunction } from '@tanstack/pacer/types'\n\n/**\n * An Angular function that creates a debounced version of a callback function.\n * This function is essentially a wrapper around `injectDebouncer` that provides\n * a simplified API for basic debouncing needs.\n *\n * The debounced function will only execute after the specified wait time has elapsed\n * since its last invocation. If called again before the wait time expires, the timer\n * resets and starts waiting again.\n *\n * This function provides a simpler API compared to `injectDebouncer`, making it ideal for basic\n * debouncing needs. However, it does not expose the underlying Debouncer instance.\n *\n * For advanced usage requiring features like:\n * - Manual cancellation\n * - Access to execution counts\n * - State tracking\n *\n * Consider using the `injectDebouncer` function instead.\n *\n * @example\n * ```ts\n * // Debounce a search handler\n * const handleSearch = injectDebouncedCallback((query: string) => {\n * fetchSearchResults(query);\n * }, {\n * wait: 500 // Wait 500ms between executions\n * });\n *\n * // Use in an input\n * <input\n * type=\"search\"\n * (input)=\"handleSearch($event.target.value)\"\n * />\n * ```\n */\nexport function injectDebouncedCallback<TFn extends AnyFunction>(\n fn: TFn,\n options: DebouncerOptions<TFn>,\n): (...args: Parameters<TFn>) => void {\n const debouncer = injectDebouncer(fn, options)\n return (...args: Parameters<TFn>) => debouncer.maybeExecute(...args)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,wBACd,IACA,SACoC;CACpC,MAAM,YAAY,gBAAgB,IAAI,OAAO;CAC7C,QAAQ,GAAG,SAA0B,UAAU,aAAa,GAAG,IAAI;AACrE"}
@@ -1 +1 @@
1
- {"version":3,"file":"injectDebouncedSignal.cjs","names":["injectDebouncer"],"sources":["../../src/debouncer/injectDebouncedSignal.ts"],"sourcesContent":["import { signal } from '@angular/core'\nimport { injectDebouncer } from './injectDebouncer'\nimport type { AngularDebouncer } from './injectDebouncer'\nimport type {\n DebouncerOptions,\n DebouncerState,\n} from '@tanstack/pacer/debouncer'\n\ntype Setter<T> = (value: T | ((prev: T) => T)) => void\n\nexport interface DebouncedSignal<TValue, TSelected = {}> {\n (): TValue\n set: Setter<TValue>\n debouncer: AngularDebouncer<Setter<TValue>, TSelected>\n}\n\n/**\n * An Angular function that creates a debounced state signal, combining Angular's signal with debouncing functionality.\n * This function provides both the current debounced value and methods to update it.\n *\n * The state value is only updated after the specified wait time has elapsed since the last update attempt.\n * If another update is attempted before the wait time expires, the timer resets and starts waiting again.\n * This is useful for handling frequent state updates that should be throttled, like search input values\n * or window resize dimensions.\n *\n * The function returns a callable object:\n * - `debounced()`: Get the current debounced value\n * - `debounced.set(...)`: Set or update the debounced value (debounced via maybeExecute)\n * - `debounced.debouncer`: The debouncer instance with additional control methods and state signals\n *\n * ## State Management and Selector\n *\n * The function uses TanStack Store for reactive state management via the underlying debouncer instance.\n * The `selector` parameter allows you to specify which debouncer state changes will trigger signal updates,\n * optimizing performance by preventing unnecessary subscriptions when irrelevant state changes occur.\n *\n * **By default, there will be no reactive state subscriptions** and you must opt-in to state\n * tracking by providing a selector function. This prevents unnecessary updates and gives you\n * full control over when your component tracks state changes. Only when you provide a selector will\n * the reactive system track the selected state values.\n *\n * Available debouncer state properties:\n * - `canLeadingExecute`: Whether the debouncer can execute on the leading edge\n * - `executionCount`: Number of function executions that have been completed\n * - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution\n * - `lastArgs`: The arguments from the most recent call to maybeExecute\n * - `status`: Current execution status ('disabled' | 'idle' | 'pending')\n *\n * @example\n * ```ts\n * const debouncedQuery = injectDebouncedSignal('', { wait: 500 })\n *\n * // Get value\n * console.log(debouncedQuery())\n *\n * // Set/update value (debounced)\n * debouncedQuery.set('hello')\n *\n * // Access debouncer\n * console.log(debouncedQuery.debouncer.state().isPending)\n * ```\n */\nexport function injectDebouncedSignal<TValue, TSelected = {}>(\n value: TValue,\n initialOptions: DebouncerOptions<Setter<TValue>>,\n selector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): DebouncedSignal<TValue, TSelected> {\n const debouncedValue = signal<TValue>(value)\n\n const debouncer = injectDebouncer(\n (newValue: TValue | ((prev: TValue) => TValue)) => {\n if (typeof newValue === 'function') {\n debouncedValue.update(newValue as (prev: TValue) => TValue)\n } else {\n debouncedValue.set(newValue)\n }\n },\n initialOptions,\n selector,\n )\n\n const set: Setter<TValue> = (\n newValue: TValue | ((prev: TValue) => TValue),\n ) => {\n debouncer.maybeExecute(newValue)\n }\n\n const debounced = Object.assign(() => debouncedValue(), {\n set,\n debouncer,\n }) as DebouncedSignal<TValue, TSelected>\n\n return debounced\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,sBACd,OACA,gBACA,UACoC;CACpC,MAAM,2CAAgC,MAAM;CAE5C,MAAM,YAAYA,yCACf,aAAkD;AACjD,MAAI,OAAO,aAAa,WACtB,gBAAe,OAAO,SAAqC;MAE3D,gBAAe,IAAI,SAAS;IAGhC,gBACA,SACD;CAED,MAAM,OACJ,aACG;AACH,YAAU,aAAa,SAAS;;AAQlC,QALkB,OAAO,aAAa,gBAAgB,EAAE;EACtD;EACA;EACD,CAAC"}
1
+ {"version":3,"file":"injectDebouncedSignal.cjs","names":["signal","injectDebouncer"],"sources":["../../src/debouncer/injectDebouncedSignal.ts"],"sourcesContent":["import { signal } from '@angular/core'\nimport { injectDebouncer } from './injectDebouncer'\nimport type { AngularDebouncer } from './injectDebouncer'\nimport type {\n DebouncerOptions,\n DebouncerState,\n} from '@tanstack/pacer/debouncer'\n\ntype Setter<T> = (value: T | ((prev: T) => T)) => void\n\nexport interface DebouncedSignal<TValue, TSelected = {}> {\n (): TValue\n set: Setter<TValue>\n debouncer: AngularDebouncer<Setter<TValue>, TSelected>\n}\n\n/**\n * An Angular function that creates a debounced state signal, combining Angular's signal with debouncing functionality.\n * This function provides both the current debounced value and methods to update it.\n *\n * The state value is only updated after the specified wait time has elapsed since the last update attempt.\n * If another update is attempted before the wait time expires, the timer resets and starts waiting again.\n * This is useful for handling frequent state updates that should be throttled, like search input values\n * or window resize dimensions.\n *\n * The function returns a callable object:\n * - `debounced()`: Get the current debounced value\n * - `debounced.set(...)`: Set or update the debounced value (debounced via maybeExecute)\n * - `debounced.debouncer`: The debouncer instance with additional control methods and state signals\n *\n * ## State Management and Selector\n *\n * The function uses TanStack Store for reactive state management via the underlying debouncer instance.\n * The `selector` parameter allows you to specify which debouncer state changes will trigger signal updates,\n * optimizing performance by preventing unnecessary subscriptions when irrelevant state changes occur.\n *\n * **By default, there will be no reactive state subscriptions** and you must opt-in to state\n * tracking by providing a selector function. This prevents unnecessary updates and gives you\n * full control over when your component tracks state changes. Only when you provide a selector will\n * the reactive system track the selected state values.\n *\n * Available debouncer state properties:\n * - `canLeadingExecute`: Whether the debouncer can execute on the leading edge\n * - `executionCount`: Number of function executions that have been completed\n * - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution\n * - `lastArgs`: The arguments from the most recent call to maybeExecute\n * - `status`: Current execution status ('disabled' | 'idle' | 'pending')\n *\n * @example\n * ```ts\n * const debouncedQuery = injectDebouncedSignal('', { wait: 500 })\n *\n * // Get value\n * console.log(debouncedQuery())\n *\n * // Set/update value (debounced)\n * debouncedQuery.set('hello')\n *\n * // Access debouncer\n * console.log(debouncedQuery.debouncer.state().isPending)\n * ```\n */\nexport function injectDebouncedSignal<TValue, TSelected = {}>(\n value: TValue,\n initialOptions: DebouncerOptions<Setter<TValue>>,\n selector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): DebouncedSignal<TValue, TSelected> {\n const debouncedValue = signal<TValue>(value)\n\n const debouncer = injectDebouncer(\n (newValue: TValue | ((prev: TValue) => TValue)) => {\n if (typeof newValue === 'function') {\n debouncedValue.update(newValue as (prev: TValue) => TValue)\n } else {\n debouncedValue.set(newValue)\n }\n },\n initialOptions,\n selector,\n )\n\n const set: Setter<TValue> = (\n newValue: TValue | ((prev: TValue) => TValue),\n ) => {\n debouncer.maybeExecute(newValue)\n }\n\n const debounced = Object.assign(() => debouncedValue(), {\n set,\n debouncer,\n }) as DebouncedSignal<TValue, TSelected>\n\n return debounced\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,sBACd,OACA,gBACA,UACoC;CACpC,MAAM,qBAAiBA,sBAAe,KAAK;CAE3C,MAAM,YAAYC,yCACf,aAAkD;EACjD,IAAI,OAAO,aAAa,YACtB,eAAe,OAAO,QAAoC;OAE1D,eAAe,IAAI,QAAQ;CAE/B,GACA,gBACA,QACF;CAEA,MAAM,OACJ,aACG;EACH,UAAU,aAAa,QAAQ;CACjC;CAOA,OALkB,OAAO,aAAa,eAAe,GAAG;EACtD;EACA;CACF,CAEe;AACjB"}
@@ -1,6 +1,5 @@
1
1
  import { AngularDebouncer } from "./injectDebouncer.cjs";
2
2
  import { DebouncerOptions, DebouncerState } from "@tanstack/pacer/debouncer";
3
-
4
3
  //#region src/debouncer/injectDebouncedSignal.d.ts
5
4
  type Setter<T> = (value: T | ((prev: T) => T)) => void;
6
5
  interface DebouncedSignal<TValue, TSelected = {}> {
@@ -1,6 +1,5 @@
1
1
  import { AngularDebouncer } from "./injectDebouncer.js";
2
2
  import { DebouncerOptions, DebouncerState } from "@tanstack/pacer/debouncer";
3
-
4
3
  //#region src/debouncer/injectDebouncedSignal.d.ts
5
4
  type Setter<T> = (value: T | ((prev: T) => T)) => void;
6
5
  interface DebouncedSignal<TValue, TSelected = {}> {
@@ -1 +1 @@
1
- {"version":3,"file":"injectDebouncedSignal.js","names":[],"sources":["../../src/debouncer/injectDebouncedSignal.ts"],"sourcesContent":["import { signal } from '@angular/core'\nimport { injectDebouncer } from './injectDebouncer'\nimport type { AngularDebouncer } from './injectDebouncer'\nimport type {\n DebouncerOptions,\n DebouncerState,\n} from '@tanstack/pacer/debouncer'\n\ntype Setter<T> = (value: T | ((prev: T) => T)) => void\n\nexport interface DebouncedSignal<TValue, TSelected = {}> {\n (): TValue\n set: Setter<TValue>\n debouncer: AngularDebouncer<Setter<TValue>, TSelected>\n}\n\n/**\n * An Angular function that creates a debounced state signal, combining Angular's signal with debouncing functionality.\n * This function provides both the current debounced value and methods to update it.\n *\n * The state value is only updated after the specified wait time has elapsed since the last update attempt.\n * If another update is attempted before the wait time expires, the timer resets and starts waiting again.\n * This is useful for handling frequent state updates that should be throttled, like search input values\n * or window resize dimensions.\n *\n * The function returns a callable object:\n * - `debounced()`: Get the current debounced value\n * - `debounced.set(...)`: Set or update the debounced value (debounced via maybeExecute)\n * - `debounced.debouncer`: The debouncer instance with additional control methods and state signals\n *\n * ## State Management and Selector\n *\n * The function uses TanStack Store for reactive state management via the underlying debouncer instance.\n * The `selector` parameter allows you to specify which debouncer state changes will trigger signal updates,\n * optimizing performance by preventing unnecessary subscriptions when irrelevant state changes occur.\n *\n * **By default, there will be no reactive state subscriptions** and you must opt-in to state\n * tracking by providing a selector function. This prevents unnecessary updates and gives you\n * full control over when your component tracks state changes. Only when you provide a selector will\n * the reactive system track the selected state values.\n *\n * Available debouncer state properties:\n * - `canLeadingExecute`: Whether the debouncer can execute on the leading edge\n * - `executionCount`: Number of function executions that have been completed\n * - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution\n * - `lastArgs`: The arguments from the most recent call to maybeExecute\n * - `status`: Current execution status ('disabled' | 'idle' | 'pending')\n *\n * @example\n * ```ts\n * const debouncedQuery = injectDebouncedSignal('', { wait: 500 })\n *\n * // Get value\n * console.log(debouncedQuery())\n *\n * // Set/update value (debounced)\n * debouncedQuery.set('hello')\n *\n * // Access debouncer\n * console.log(debouncedQuery.debouncer.state().isPending)\n * ```\n */\nexport function injectDebouncedSignal<TValue, TSelected = {}>(\n value: TValue,\n initialOptions: DebouncerOptions<Setter<TValue>>,\n selector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): DebouncedSignal<TValue, TSelected> {\n const debouncedValue = signal<TValue>(value)\n\n const debouncer = injectDebouncer(\n (newValue: TValue | ((prev: TValue) => TValue)) => {\n if (typeof newValue === 'function') {\n debouncedValue.update(newValue as (prev: TValue) => TValue)\n } else {\n debouncedValue.set(newValue)\n }\n },\n initialOptions,\n selector,\n )\n\n const set: Setter<TValue> = (\n newValue: TValue | ((prev: TValue) => TValue),\n ) => {\n debouncer.maybeExecute(newValue)\n }\n\n const debounced = Object.assign(() => debouncedValue(), {\n set,\n debouncer,\n }) as DebouncedSignal<TValue, TSelected>\n\n return debounced\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,sBACd,OACA,gBACA,UACoC;CACpC,MAAM,iBAAiB,OAAe,MAAM;CAE5C,MAAM,YAAY,iBACf,aAAkD;AACjD,MAAI,OAAO,aAAa,WACtB,gBAAe,OAAO,SAAqC;MAE3D,gBAAe,IAAI,SAAS;IAGhC,gBACA,SACD;CAED,MAAM,OACJ,aACG;AACH,YAAU,aAAa,SAAS;;AAQlC,QALkB,OAAO,aAAa,gBAAgB,EAAE;EACtD;EACA;EACD,CAAC"}
1
+ {"version":3,"file":"injectDebouncedSignal.js","names":[],"sources":["../../src/debouncer/injectDebouncedSignal.ts"],"sourcesContent":["import { signal } from '@angular/core'\nimport { injectDebouncer } from './injectDebouncer'\nimport type { AngularDebouncer } from './injectDebouncer'\nimport type {\n DebouncerOptions,\n DebouncerState,\n} from '@tanstack/pacer/debouncer'\n\ntype Setter<T> = (value: T | ((prev: T) => T)) => void\n\nexport interface DebouncedSignal<TValue, TSelected = {}> {\n (): TValue\n set: Setter<TValue>\n debouncer: AngularDebouncer<Setter<TValue>, TSelected>\n}\n\n/**\n * An Angular function that creates a debounced state signal, combining Angular's signal with debouncing functionality.\n * This function provides both the current debounced value and methods to update it.\n *\n * The state value is only updated after the specified wait time has elapsed since the last update attempt.\n * If another update is attempted before the wait time expires, the timer resets and starts waiting again.\n * This is useful for handling frequent state updates that should be throttled, like search input values\n * or window resize dimensions.\n *\n * The function returns a callable object:\n * - `debounced()`: Get the current debounced value\n * - `debounced.set(...)`: Set or update the debounced value (debounced via maybeExecute)\n * - `debounced.debouncer`: The debouncer instance with additional control methods and state signals\n *\n * ## State Management and Selector\n *\n * The function uses TanStack Store for reactive state management via the underlying debouncer instance.\n * The `selector` parameter allows you to specify which debouncer state changes will trigger signal updates,\n * optimizing performance by preventing unnecessary subscriptions when irrelevant state changes occur.\n *\n * **By default, there will be no reactive state subscriptions** and you must opt-in to state\n * tracking by providing a selector function. This prevents unnecessary updates and gives you\n * full control over when your component tracks state changes. Only when you provide a selector will\n * the reactive system track the selected state values.\n *\n * Available debouncer state properties:\n * - `canLeadingExecute`: Whether the debouncer can execute on the leading edge\n * - `executionCount`: Number of function executions that have been completed\n * - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution\n * - `lastArgs`: The arguments from the most recent call to maybeExecute\n * - `status`: Current execution status ('disabled' | 'idle' | 'pending')\n *\n * @example\n * ```ts\n * const debouncedQuery = injectDebouncedSignal('', { wait: 500 })\n *\n * // Get value\n * console.log(debouncedQuery())\n *\n * // Set/update value (debounced)\n * debouncedQuery.set('hello')\n *\n * // Access debouncer\n * console.log(debouncedQuery.debouncer.state().isPending)\n * ```\n */\nexport function injectDebouncedSignal<TValue, TSelected = {}>(\n value: TValue,\n initialOptions: DebouncerOptions<Setter<TValue>>,\n selector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): DebouncedSignal<TValue, TSelected> {\n const debouncedValue = signal<TValue>(value)\n\n const debouncer = injectDebouncer(\n (newValue: TValue | ((prev: TValue) => TValue)) => {\n if (typeof newValue === 'function') {\n debouncedValue.update(newValue as (prev: TValue) => TValue)\n } else {\n debouncedValue.set(newValue)\n }\n },\n initialOptions,\n selector,\n )\n\n const set: Setter<TValue> = (\n newValue: TValue | ((prev: TValue) => TValue),\n ) => {\n debouncer.maybeExecute(newValue)\n }\n\n const debounced = Object.assign(() => debouncedValue(), {\n set,\n debouncer,\n }) as DebouncedSignal<TValue, TSelected>\n\n return debounced\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,sBACd,OACA,gBACA,UACoC;CACpC,MAAM,iBAAiB,OAAe,KAAK;CAE3C,MAAM,YAAY,iBACf,aAAkD;EACjD,IAAI,OAAO,aAAa,YACtB,eAAe,OAAO,QAAoC;OAE1D,eAAe,IAAI,QAAQ;CAE/B,GACA,gBACA,QACF;CAEA,MAAM,OACJ,aACG;EACH,UAAU,aAAa,QAAQ;CACjC;CAOA,OALkB,OAAO,aAAa,eAAe,GAAG;EACtD;EACA;CACF,CAEe;AACjB"}
@@ -1 +1 @@
1
- {"version":3,"file":"injectDebouncedValue.cjs","names":["injectDebouncedSignal"],"sources":["../../src/debouncer/injectDebouncedValue.ts"],"sourcesContent":["import { effect } from '@angular/core'\nimport { injectDebouncedSignal } from './injectDebouncedSignal'\nimport type { DebouncedSignal } from './injectDebouncedSignal'\nimport type { Signal } from '@angular/core'\nimport type {\n DebouncerOptions,\n DebouncerState,\n} from '@tanstack/pacer/debouncer'\n\ntype Setter<T> = (value: T | ((prev: T) => T)) => void\n\n/**\n * An Angular function that creates a debounced value that updates only after a specified delay.\n * Unlike injectDebouncedSignal, this function automatically tracks changes to the input signal\n * and updates the debounced value accordingly.\n *\n * The debounced value will only update after the specified wait time has elapsed since\n * the last change to the input value. If the input value changes again before the wait\n * time expires, the timer resets and starts waiting again.\n *\n * This is useful for deriving debounced values from signals that change frequently,\n * like search queries or form inputs, where you want to limit how often downstream effects\n * or calculations occur.\n *\n * The function returns a tuple containing:\n * - A Signal that provides the current debounced value\n * - The debouncer instance with control methods\n *\n * ## State Management and Selector\n *\n * The function uses TanStack Store for reactive state management via the underlying debouncer instance.\n * The `selector` parameter allows you to specify which debouncer state changes will trigger signal updates,\n * optimizing performance by preventing unnecessary subscriptions when irrelevant state changes occur.\n *\n * **By default, there will be no reactive state subscriptions** and you must opt-in to state\n * tracking by providing a selector function. This prevents unnecessary updates and gives you\n * full control over when your component tracks state changes. Only when you provide a selector will\n * the reactive system track the selected state values.\n *\n * Available debouncer state properties:\n * - `canLeadingExecute`: Whether the debouncer can execute on the leading edge\n * - `executionCount`: Number of function executions that have been completed\n * - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution\n * - `lastArgs`: The arguments from the most recent call to maybeExecute\n * - `status`: Current execution status ('disabled' | 'idle' | 'pending')\n *\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const searchQuery = signal('')\n * const debounced = injectDebouncedValue(searchQuery, {\n * wait: 500, // Wait 500ms after last change\n * })\n *\n * // Opt-in to reactive updates when pending state changes (optimized for loading indicators)\n * const debouncedWithPending = injectDebouncedValue(\n * searchQuery,\n * { wait: 500 },\n * (state) => ({ isPending: state.isPending }),\n * )\n *\n * // Debounced value will update 500ms after searchQuery stops changing\n * effect(() => {\n * fetchSearchResults(debounced())\n * })\n *\n * // Access selected debouncer state via signals (only if you provided a selector)\n * effect(() => {\n * console.log('Is pending:', debouncedWithPending.state().isPending)\n * })\n *\n * // Control the debouncer\n * debounced.cancel() // Cancel any pending updates\n * ```\n */\nexport function injectDebouncedValue<TValue, TSelected = {}>(\n value: Signal<TValue>,\n initialOptions: DebouncerOptions<Setter<TValue>>,\n selector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): DebouncedSignal<TValue, TSelected>\nexport function injectDebouncedValue<TValue, TSelected = {}>(\n value: Signal<TValue>,\n initialValue: TValue,\n initialOptions: DebouncerOptions<Setter<TValue>>,\n selector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): DebouncedSignal<TValue, TSelected>\nexport function injectDebouncedValue<TValue, TSelected = {}>(\n value: Signal<TValue>,\n initialValueOrOptions: TValue | DebouncerOptions<Setter<TValue>>,\n initialOptionsOrSelector?:\n | DebouncerOptions<Setter<TValue>>\n | ((state: DebouncerState<Setter<TValue>>) => TSelected),\n maybeSelector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): DebouncedSignal<TValue, TSelected> {\n const hasSelector = typeof initialOptionsOrSelector === 'function'\n\n const hasInitialValue =\n (initialOptionsOrSelector !== undefined && !hasSelector) ||\n maybeSelector !== undefined\n\n const initialValue = hasInitialValue\n ? (initialValueOrOptions as TValue)\n : (undefined as unknown as TValue)\n const initialOptions = hasInitialValue\n ? (initialOptionsOrSelector as DebouncerOptions<Setter<TValue>>)\n : (initialValueOrOptions as DebouncerOptions<Setter<TValue>>)\n const selector = hasInitialValue\n ? maybeSelector\n : (initialOptionsOrSelector as\n | ((state: DebouncerState<Setter<TValue>>) => TSelected)\n | undefined)\n\n const debounced = injectDebouncedSignal(\n initialValue,\n initialOptions,\n selector,\n )\n\n effect(() => {\n const latest = value()\n debounced.set(latest)\n })\n\n return debounced\n}\n"],"mappings":";;;;AAuFA,SAAgB,qBACd,OACA,uBACA,0BAGA,eACoC;CAGpC,MAAM,kBACH,6BAA6B,UAAa,EAHzB,OAAO,6BAA6B,eAItD,kBAAkB;CAcpB,MAAM,YAAYA,oDAZG,kBAChB,wBACA,QACkB,kBAClB,2BACA,uBACY,kBACb,gBACC,yBAQJ;AAED,iCAAa;EACX,MAAM,SAAS,OAAO;AACtB,YAAU,IAAI,OAAO;GACrB;AAEF,QAAO"}
1
+ {"version":3,"file":"injectDebouncedValue.cjs","names":["injectDebouncedSignal"],"sources":["../../src/debouncer/injectDebouncedValue.ts"],"sourcesContent":["import { effect } from '@angular/core'\nimport { injectDebouncedSignal } from './injectDebouncedSignal'\nimport type { DebouncedSignal } from './injectDebouncedSignal'\nimport type { Signal } from '@angular/core'\nimport type {\n DebouncerOptions,\n DebouncerState,\n} from '@tanstack/pacer/debouncer'\n\ntype Setter<T> = (value: T | ((prev: T) => T)) => void\n\n/**\n * An Angular function that creates a debounced value that updates only after a specified delay.\n * Unlike injectDebouncedSignal, this function automatically tracks changes to the input signal\n * and updates the debounced value accordingly.\n *\n * The debounced value will only update after the specified wait time has elapsed since\n * the last change to the input value. If the input value changes again before the wait\n * time expires, the timer resets and starts waiting again.\n *\n * This is useful for deriving debounced values from signals that change frequently,\n * like search queries or form inputs, where you want to limit how often downstream effects\n * or calculations occur.\n *\n * The function returns a tuple containing:\n * - A Signal that provides the current debounced value\n * - The debouncer instance with control methods\n *\n * ## State Management and Selector\n *\n * The function uses TanStack Store for reactive state management via the underlying debouncer instance.\n * The `selector` parameter allows you to specify which debouncer state changes will trigger signal updates,\n * optimizing performance by preventing unnecessary subscriptions when irrelevant state changes occur.\n *\n * **By default, there will be no reactive state subscriptions** and you must opt-in to state\n * tracking by providing a selector function. This prevents unnecessary updates and gives you\n * full control over when your component tracks state changes. Only when you provide a selector will\n * the reactive system track the selected state values.\n *\n * Available debouncer state properties:\n * - `canLeadingExecute`: Whether the debouncer can execute on the leading edge\n * - `executionCount`: Number of function executions that have been completed\n * - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution\n * - `lastArgs`: The arguments from the most recent call to maybeExecute\n * - `status`: Current execution status ('disabled' | 'idle' | 'pending')\n *\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const searchQuery = signal('')\n * const debounced = injectDebouncedValue(searchQuery, {\n * wait: 500, // Wait 500ms after last change\n * })\n *\n * // Opt-in to reactive updates when pending state changes (optimized for loading indicators)\n * const debouncedWithPending = injectDebouncedValue(\n * searchQuery,\n * { wait: 500 },\n * (state) => ({ isPending: state.isPending }),\n * )\n *\n * // Debounced value will update 500ms after searchQuery stops changing\n * effect(() => {\n * fetchSearchResults(debounced())\n * })\n *\n * // Access selected debouncer state via signals (only if you provided a selector)\n * effect(() => {\n * console.log('Is pending:', debouncedWithPending.state().isPending)\n * })\n *\n * // Control the debouncer\n * debounced.cancel() // Cancel any pending updates\n * ```\n */\nexport function injectDebouncedValue<TValue, TSelected = {}>(\n value: Signal<TValue>,\n initialOptions: DebouncerOptions<Setter<TValue>>,\n selector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): DebouncedSignal<TValue, TSelected>\nexport function injectDebouncedValue<TValue, TSelected = {}>(\n value: Signal<TValue>,\n initialValue: TValue,\n initialOptions: DebouncerOptions<Setter<TValue>>,\n selector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): DebouncedSignal<TValue, TSelected>\nexport function injectDebouncedValue<TValue, TSelected = {}>(\n value: Signal<TValue>,\n initialValueOrOptions: TValue | DebouncerOptions<Setter<TValue>>,\n initialOptionsOrSelector?:\n | DebouncerOptions<Setter<TValue>>\n | ((state: DebouncerState<Setter<TValue>>) => TSelected),\n maybeSelector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): DebouncedSignal<TValue, TSelected> {\n const hasSelector = typeof initialOptionsOrSelector === 'function'\n\n const hasInitialValue =\n (initialOptionsOrSelector !== undefined && !hasSelector) ||\n maybeSelector !== undefined\n\n const initialValue = hasInitialValue\n ? (initialValueOrOptions as TValue)\n : (undefined as unknown as TValue)\n const initialOptions = hasInitialValue\n ? (initialOptionsOrSelector as DebouncerOptions<Setter<TValue>>)\n : (initialValueOrOptions as DebouncerOptions<Setter<TValue>>)\n const selector = hasInitialValue\n ? maybeSelector\n : (initialOptionsOrSelector as\n ((state: DebouncerState<Setter<TValue>>) => TSelected) | undefined)\n\n const debounced = injectDebouncedSignal(\n initialValue,\n initialOptions,\n selector,\n )\n\n effect(() => {\n const latest = value()\n debounced.set(latest)\n })\n\n return debounced\n}\n"],"mappings":";;;;AAuFA,SAAgB,qBACd,OACA,uBACA,0BAGA,eACoC;CAGpC,MAAM,kBACH,6BAA6B,UAAa,EAHzB,OAAO,6BAA6B,eAItD,kBAAkB;CAapB,MAAM,YAAYA,oDAXG,kBAChB,wBACA,QACkB,kBAClB,2BACA,uBACY,kBACb,gBACC,wBAOL;CAEA,gCAAa;EACX,MAAM,SAAS,MAAM;EACrB,UAAU,IAAI,MAAM;CACtB,CAAC;CAED,OAAO;AACT"}
@@ -1,7 +1,6 @@
1
1
  import { DebouncedSignal } from "./injectDebouncedSignal.cjs";
2
2
  import { Signal } from "@angular/core";
3
3
  import { DebouncerOptions, DebouncerState } from "@tanstack/pacer/debouncer";
4
-
5
4
  //#region src/debouncer/injectDebouncedValue.d.ts
6
5
  type Setter<T> = (value: T | ((prev: T) => T)) => void;
7
6
  /**
@@ -1,7 +1,6 @@
1
1
  import { DebouncedSignal } from "./injectDebouncedSignal.js";
2
2
  import { Signal } from "@angular/core";
3
3
  import { DebouncerOptions, DebouncerState } from "@tanstack/pacer/debouncer";
4
-
5
4
  //#region src/debouncer/injectDebouncedValue.d.ts
6
5
  type Setter<T> = (value: T | ((prev: T) => T)) => void;
7
6
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"injectDebouncedValue.js","names":[],"sources":["../../src/debouncer/injectDebouncedValue.ts"],"sourcesContent":["import { effect } from '@angular/core'\nimport { injectDebouncedSignal } from './injectDebouncedSignal'\nimport type { DebouncedSignal } from './injectDebouncedSignal'\nimport type { Signal } from '@angular/core'\nimport type {\n DebouncerOptions,\n DebouncerState,\n} from '@tanstack/pacer/debouncer'\n\ntype Setter<T> = (value: T | ((prev: T) => T)) => void\n\n/**\n * An Angular function that creates a debounced value that updates only after a specified delay.\n * Unlike injectDebouncedSignal, this function automatically tracks changes to the input signal\n * and updates the debounced value accordingly.\n *\n * The debounced value will only update after the specified wait time has elapsed since\n * the last change to the input value. If the input value changes again before the wait\n * time expires, the timer resets and starts waiting again.\n *\n * This is useful for deriving debounced values from signals that change frequently,\n * like search queries or form inputs, where you want to limit how often downstream effects\n * or calculations occur.\n *\n * The function returns a tuple containing:\n * - A Signal that provides the current debounced value\n * - The debouncer instance with control methods\n *\n * ## State Management and Selector\n *\n * The function uses TanStack Store for reactive state management via the underlying debouncer instance.\n * The `selector` parameter allows you to specify which debouncer state changes will trigger signal updates,\n * optimizing performance by preventing unnecessary subscriptions when irrelevant state changes occur.\n *\n * **By default, there will be no reactive state subscriptions** and you must opt-in to state\n * tracking by providing a selector function. This prevents unnecessary updates and gives you\n * full control over when your component tracks state changes. Only when you provide a selector will\n * the reactive system track the selected state values.\n *\n * Available debouncer state properties:\n * - `canLeadingExecute`: Whether the debouncer can execute on the leading edge\n * - `executionCount`: Number of function executions that have been completed\n * - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution\n * - `lastArgs`: The arguments from the most recent call to maybeExecute\n * - `status`: Current execution status ('disabled' | 'idle' | 'pending')\n *\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const searchQuery = signal('')\n * const debounced = injectDebouncedValue(searchQuery, {\n * wait: 500, // Wait 500ms after last change\n * })\n *\n * // Opt-in to reactive updates when pending state changes (optimized for loading indicators)\n * const debouncedWithPending = injectDebouncedValue(\n * searchQuery,\n * { wait: 500 },\n * (state) => ({ isPending: state.isPending }),\n * )\n *\n * // Debounced value will update 500ms after searchQuery stops changing\n * effect(() => {\n * fetchSearchResults(debounced())\n * })\n *\n * // Access selected debouncer state via signals (only if you provided a selector)\n * effect(() => {\n * console.log('Is pending:', debouncedWithPending.state().isPending)\n * })\n *\n * // Control the debouncer\n * debounced.cancel() // Cancel any pending updates\n * ```\n */\nexport function injectDebouncedValue<TValue, TSelected = {}>(\n value: Signal<TValue>,\n initialOptions: DebouncerOptions<Setter<TValue>>,\n selector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): DebouncedSignal<TValue, TSelected>\nexport function injectDebouncedValue<TValue, TSelected = {}>(\n value: Signal<TValue>,\n initialValue: TValue,\n initialOptions: DebouncerOptions<Setter<TValue>>,\n selector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): DebouncedSignal<TValue, TSelected>\nexport function injectDebouncedValue<TValue, TSelected = {}>(\n value: Signal<TValue>,\n initialValueOrOptions: TValue | DebouncerOptions<Setter<TValue>>,\n initialOptionsOrSelector?:\n | DebouncerOptions<Setter<TValue>>\n | ((state: DebouncerState<Setter<TValue>>) => TSelected),\n maybeSelector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): DebouncedSignal<TValue, TSelected> {\n const hasSelector = typeof initialOptionsOrSelector === 'function'\n\n const hasInitialValue =\n (initialOptionsOrSelector !== undefined && !hasSelector) ||\n maybeSelector !== undefined\n\n const initialValue = hasInitialValue\n ? (initialValueOrOptions as TValue)\n : (undefined as unknown as TValue)\n const initialOptions = hasInitialValue\n ? (initialOptionsOrSelector as DebouncerOptions<Setter<TValue>>)\n : (initialValueOrOptions as DebouncerOptions<Setter<TValue>>)\n const selector = hasInitialValue\n ? maybeSelector\n : (initialOptionsOrSelector as\n | ((state: DebouncerState<Setter<TValue>>) => TSelected)\n | undefined)\n\n const debounced = injectDebouncedSignal(\n initialValue,\n initialOptions,\n selector,\n )\n\n effect(() => {\n const latest = value()\n debounced.set(latest)\n })\n\n return debounced\n}\n"],"mappings":";;;;AAuFA,SAAgB,qBACd,OACA,uBACA,0BAGA,eACoC;CAGpC,MAAM,kBACH,6BAA6B,UAAa,EAHzB,OAAO,6BAA6B,eAItD,kBAAkB;CAcpB,MAAM,YAAY,sBAZG,kBAChB,wBACA,QACkB,kBAClB,2BACA,uBACY,kBACb,gBACC,yBAQJ;AAED,cAAa;EACX,MAAM,SAAS,OAAO;AACtB,YAAU,IAAI,OAAO;GACrB;AAEF,QAAO"}
1
+ {"version":3,"file":"injectDebouncedValue.js","names":[],"sources":["../../src/debouncer/injectDebouncedValue.ts"],"sourcesContent":["import { effect } from '@angular/core'\nimport { injectDebouncedSignal } from './injectDebouncedSignal'\nimport type { DebouncedSignal } from './injectDebouncedSignal'\nimport type { Signal } from '@angular/core'\nimport type {\n DebouncerOptions,\n DebouncerState,\n} from '@tanstack/pacer/debouncer'\n\ntype Setter<T> = (value: T | ((prev: T) => T)) => void\n\n/**\n * An Angular function that creates a debounced value that updates only after a specified delay.\n * Unlike injectDebouncedSignal, this function automatically tracks changes to the input signal\n * and updates the debounced value accordingly.\n *\n * The debounced value will only update after the specified wait time has elapsed since\n * the last change to the input value. If the input value changes again before the wait\n * time expires, the timer resets and starts waiting again.\n *\n * This is useful for deriving debounced values from signals that change frequently,\n * like search queries or form inputs, where you want to limit how often downstream effects\n * or calculations occur.\n *\n * The function returns a tuple containing:\n * - A Signal that provides the current debounced value\n * - The debouncer instance with control methods\n *\n * ## State Management and Selector\n *\n * The function uses TanStack Store for reactive state management via the underlying debouncer instance.\n * The `selector` parameter allows you to specify which debouncer state changes will trigger signal updates,\n * optimizing performance by preventing unnecessary subscriptions when irrelevant state changes occur.\n *\n * **By default, there will be no reactive state subscriptions** and you must opt-in to state\n * tracking by providing a selector function. This prevents unnecessary updates and gives you\n * full control over when your component tracks state changes. Only when you provide a selector will\n * the reactive system track the selected state values.\n *\n * Available debouncer state properties:\n * - `canLeadingExecute`: Whether the debouncer can execute on the leading edge\n * - `executionCount`: Number of function executions that have been completed\n * - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution\n * - `lastArgs`: The arguments from the most recent call to maybeExecute\n * - `status`: Current execution status ('disabled' | 'idle' | 'pending')\n *\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const searchQuery = signal('')\n * const debounced = injectDebouncedValue(searchQuery, {\n * wait: 500, // Wait 500ms after last change\n * })\n *\n * // Opt-in to reactive updates when pending state changes (optimized for loading indicators)\n * const debouncedWithPending = injectDebouncedValue(\n * searchQuery,\n * { wait: 500 },\n * (state) => ({ isPending: state.isPending }),\n * )\n *\n * // Debounced value will update 500ms after searchQuery stops changing\n * effect(() => {\n * fetchSearchResults(debounced())\n * })\n *\n * // Access selected debouncer state via signals (only if you provided a selector)\n * effect(() => {\n * console.log('Is pending:', debouncedWithPending.state().isPending)\n * })\n *\n * // Control the debouncer\n * debounced.cancel() // Cancel any pending updates\n * ```\n */\nexport function injectDebouncedValue<TValue, TSelected = {}>(\n value: Signal<TValue>,\n initialOptions: DebouncerOptions<Setter<TValue>>,\n selector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): DebouncedSignal<TValue, TSelected>\nexport function injectDebouncedValue<TValue, TSelected = {}>(\n value: Signal<TValue>,\n initialValue: TValue,\n initialOptions: DebouncerOptions<Setter<TValue>>,\n selector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): DebouncedSignal<TValue, TSelected>\nexport function injectDebouncedValue<TValue, TSelected = {}>(\n value: Signal<TValue>,\n initialValueOrOptions: TValue | DebouncerOptions<Setter<TValue>>,\n initialOptionsOrSelector?:\n | DebouncerOptions<Setter<TValue>>\n | ((state: DebouncerState<Setter<TValue>>) => TSelected),\n maybeSelector?: (state: DebouncerState<Setter<TValue>>) => TSelected,\n): DebouncedSignal<TValue, TSelected> {\n const hasSelector = typeof initialOptionsOrSelector === 'function'\n\n const hasInitialValue =\n (initialOptionsOrSelector !== undefined && !hasSelector) ||\n maybeSelector !== undefined\n\n const initialValue = hasInitialValue\n ? (initialValueOrOptions as TValue)\n : (undefined as unknown as TValue)\n const initialOptions = hasInitialValue\n ? (initialOptionsOrSelector as DebouncerOptions<Setter<TValue>>)\n : (initialValueOrOptions as DebouncerOptions<Setter<TValue>>)\n const selector = hasInitialValue\n ? maybeSelector\n : (initialOptionsOrSelector as\n ((state: DebouncerState<Setter<TValue>>) => TSelected) | undefined)\n\n const debounced = injectDebouncedSignal(\n initialValue,\n initialOptions,\n selector,\n )\n\n effect(() => {\n const latest = value()\n debounced.set(latest)\n })\n\n return debounced\n}\n"],"mappings":";;;;AAuFA,SAAgB,qBACd,OACA,uBACA,0BAGA,eACoC;CAGpC,MAAM,kBACH,6BAA6B,UAAa,EAHzB,OAAO,6BAA6B,eAItD,kBAAkB;CAapB,MAAM,YAAY,sBAXG,kBAChB,wBACA,QACkB,kBAClB,2BACA,uBACY,kBACb,gBACC,wBAOL;CAEA,aAAa;EACX,MAAM,SAAS,MAAM;EACrB,UAAU,IAAI,MAAM;CACtB,CAAC;CAED,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"injectDebouncer.cjs","names":["injectPacerOptions","Debouncer","DestroyRef"],"sources":["../../src/debouncer/injectDebouncer.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { Debouncer } from '@tanstack/pacer/debouncer'\nimport { injectPacerOptions } from '../provider/pacer-context'\nimport type { Signal } from '@angular/core'\nimport type { Store } from '@tanstack/angular-store'\nimport type { AnyFunction } from '@tanstack/pacer/types'\nimport type {\n DebouncerOptions,\n DebouncerState,\n} from '@tanstack/pacer/debouncer'\n\nexport interface AngularDebouncerOptions<\n TFn extends AnyFunction,\n TSelected = {},\n> extends DebouncerOptions<TFn> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the debouncer instance.\n * When provided, replaces the default cleanup (cancel); use it to call flush(), cancel(), add logging, etc.\n */\n onUnmount?: (debouncer: AngularDebouncer<TFn, TSelected>) => void\n}\n\nexport interface AngularDebouncer<\n TFn extends AnyFunction,\n TSelected = {},\n> extends Omit<Debouncer<TFn>, 'store'> {\n /**\n * Reactive state signal that will be updated when the debouncer state changes\n *\n * Use this instead of `debouncer.store.state`\n */\n readonly state: Signal<Readonly<TSelected>>\n /**\n * @deprecated Use `debouncer.state` instead of `debouncer.store.state` if you want to read reactive state.\n * The state on the store object is not reactive in Angular signals.\n */\n readonly store: Store<Readonly<DebouncerState<TFn>>>\n}\n\n/**\n * An Angular function that creates and manages a Debouncer instance.\n *\n * This is a lower-level function that provides direct access to the Debouncer's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * This function provides debouncing functionality to limit how often a function can be called,\n * waiting for a specified delay before executing the latest call. This is useful for handling\n * frequent events like window resizing, scroll events, or real-time search inputs.\n *\n * The debouncer will only execute the function after the specified wait time has elapsed\n * since the last call. If the function is called again before the wait time expires, the\n * timer resets and starts waiting again.\n *\n * ## State Management and Selector\n *\n * The function uses TanStack Store for state management and wraps it with Angular signals.\n * The `selector` parameter allows you to specify which state changes will trigger signal updates,\n * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.\n *\n * **By default, there will be no reactive state subscriptions** and you must opt-in to state\n * tracking by providing a selector function. This prevents unnecessary updates and gives you\n * full control over when your component tracks state changes.\n *\n * Available state properties:\n * - `canLeadingExecute`: Whether the debouncer can execute on the leading edge\n * - `executionCount`: Number of function executions that have been completed\n * - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution\n * - `lastArgs`: The arguments from the most recent call to maybeExecute\n * - `status`: Current execution status ('disabled' | 'idle' | 'pending')\n *\n * ## Cleanup on Destroy\n *\n * By default, the function cancels any pending execution when the component is destroyed.\n * Use the `onUnmount` option to customize this. For example, to flush pending work instead:\n *\n * ```ts\n * const debouncer = injectDebouncer(fn, {\n * wait: 500,\n * onUnmount: (d) => d.flush()\n * });\n * ```\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const debouncer = injectDebouncer(\n * (query: string) => fetchSearchResults(query),\n * { wait: 500 }\n * );\n *\n * // Opt-in to track isPending changes (optimized for loading states)\n * const debouncer = injectDebouncer(\n * (query: string) => fetchSearchResults(query),\n * { wait: 500 },\n * (state) => ({ isPending: state.isPending })\n * );\n *\n * // In an event handler\n * const handleChange = (e: Event) => {\n * const target = e.target as HTMLInputElement\n * debouncer.maybeExecute(target.value);\n * };\n *\n * // Access the selected state (will be empty object {} unless selector provided)\n * const { isPending } = debouncer.state();\n * ```\n */\nexport function injectDebouncer<TFn extends AnyFunction, TSelected = {}>(\n fn: TFn,\n options: AngularDebouncerOptions<TFn, TSelected>,\n selector: (state: DebouncerState<TFn>) => TSelected = () => ({}) as TSelected,\n): AngularDebouncer<TFn, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().debouncer,\n ...options,\n } as AngularDebouncerOptions<TFn, TSelected>\n\n const debouncer = new Debouncer<TFn>(fn, mergedOptions)\n const state = injectSelector(debouncer.store, selector)\n\n const result = {\n ...debouncer,\n state,\n } as AngularDebouncer<TFn, TSelected>\n\n const destroyRef = inject(DestroyRef, { optional: true })\n destroyRef?.onDestroy(() => {\n if (mergedOptions.onUnmount) {\n mergedOptions.onUnmount(result)\n } else {\n debouncer.cancel()\n }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4GA,SAAgB,gBACd,IACA,SACA,kBAA6D,EAAE,GAC7B;CAClC,MAAM,gBAAgB;EACpB,GAAGA,0CAAoB,CAAC;EACxB,GAAG;EACJ;CAED,MAAM,YAAY,IAAIC,oCAAe,IAAI,cAAc;CACvD,MAAM,oDAAuB,UAAU,OAAO,SAAS;CAEvD,MAAM,SAAS;EACb,GAAG;EACH;EACD;AAGD,2BAD0BC,0BAAY,EAAE,UAAU,MAAM,CAAC,EAC7C,gBAAgB;AAC1B,MAAI,cAAc,UAChB,eAAc,UAAU,OAAO;MAE/B,WAAU,QAAQ;GAEpB;AAEF,QAAO"}
1
+ {"version":3,"file":"injectDebouncer.cjs","names":["injectPacerOptions","Debouncer","injectSelector","inject","DestroyRef"],"sources":["../../src/debouncer/injectDebouncer.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { Debouncer } from '@tanstack/pacer/debouncer'\nimport { injectPacerOptions } from '../provider/pacer-context'\nimport type { Signal } from '@angular/core'\nimport type { Store } from '@tanstack/angular-store'\nimport type { AnyFunction } from '@tanstack/pacer/types'\nimport type {\n DebouncerOptions,\n DebouncerState,\n} from '@tanstack/pacer/debouncer'\n\nexport interface AngularDebouncerOptions<\n TFn extends AnyFunction,\n TSelected = {},\n> extends DebouncerOptions<TFn> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the debouncer instance.\n * When provided, replaces the default cleanup (cancel); use it to call flush(), cancel(), add logging, etc.\n */\n onUnmount?: (debouncer: AngularDebouncer<TFn, TSelected>) => void\n}\n\nexport interface AngularDebouncer<\n TFn extends AnyFunction,\n TSelected = {},\n> extends Omit<Debouncer<TFn>, 'store'> {\n /**\n * Reactive state signal that will be updated when the debouncer state changes\n *\n * Use this instead of `debouncer.store.state`\n */\n readonly state: Signal<Readonly<TSelected>>\n /**\n * @deprecated Use `debouncer.state` instead of `debouncer.store.state` if you want to read reactive state.\n * The state on the store object is not reactive in Angular signals.\n */\n readonly store: Store<Readonly<DebouncerState<TFn>>>\n}\n\n/**\n * An Angular function that creates and manages a Debouncer instance.\n *\n * This is a lower-level function that provides direct access to the Debouncer's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * This function provides debouncing functionality to limit how often a function can be called,\n * waiting for a specified delay before executing the latest call. This is useful for handling\n * frequent events like window resizing, scroll events, or real-time search inputs.\n *\n * The debouncer will only execute the function after the specified wait time has elapsed\n * since the last call. If the function is called again before the wait time expires, the\n * timer resets and starts waiting again.\n *\n * ## State Management and Selector\n *\n * The function uses TanStack Store for state management and wraps it with Angular signals.\n * The `selector` parameter allows you to specify which state changes will trigger signal updates,\n * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.\n *\n * **By default, there will be no reactive state subscriptions** and you must opt-in to state\n * tracking by providing a selector function. This prevents unnecessary updates and gives you\n * full control over when your component tracks state changes.\n *\n * Available state properties:\n * - `canLeadingExecute`: Whether the debouncer can execute on the leading edge\n * - `executionCount`: Number of function executions that have been completed\n * - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution\n * - `lastArgs`: The arguments from the most recent call to maybeExecute\n * - `status`: Current execution status ('disabled' | 'idle' | 'pending')\n *\n * ## Cleanup on Destroy\n *\n * By default, the function cancels any pending execution when the component is destroyed.\n * Use the `onUnmount` option to customize this. For example, to flush pending work instead:\n *\n * ```ts\n * const debouncer = injectDebouncer(fn, {\n * wait: 500,\n * onUnmount: (d) => d.flush()\n * });\n * ```\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const debouncer = injectDebouncer(\n * (query: string) => fetchSearchResults(query),\n * { wait: 500 }\n * );\n *\n * // Opt-in to track isPending changes (optimized for loading states)\n * const debouncer = injectDebouncer(\n * (query: string) => fetchSearchResults(query),\n * { wait: 500 },\n * (state) => ({ isPending: state.isPending })\n * );\n *\n * // In an event handler\n * const handleChange = (e: Event) => {\n * const target = e.target as HTMLInputElement\n * debouncer.maybeExecute(target.value);\n * };\n *\n * // Access the selected state (will be empty object {} unless selector provided)\n * const { isPending } = debouncer.state();\n * ```\n */\nexport function injectDebouncer<TFn extends AnyFunction, TSelected = {}>(\n fn: TFn,\n options: AngularDebouncerOptions<TFn, TSelected>,\n selector: (state: DebouncerState<TFn>) => TSelected = () => ({}) as TSelected,\n): AngularDebouncer<TFn, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().debouncer,\n ...options,\n } as AngularDebouncerOptions<TFn, TSelected>\n\n const debouncer = new Debouncer<TFn>(fn, mergedOptions)\n const state = injectSelector(debouncer.store, selector)\n\n const result = {\n ...debouncer,\n state,\n } as AngularDebouncer<TFn, TSelected>\n\n const destroyRef = inject(DestroyRef, { optional: true })\n destroyRef?.onDestroy(() => {\n if (mergedOptions.onUnmount) {\n mergedOptions.onUnmount(result)\n } else {\n debouncer.cancel()\n }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4GA,SAAgB,gBACd,IACA,SACA,kBAA6D,CAAC,IAC5B;CAClC,MAAM,gBAAgB;EACpB,GAAGA,yCAAmB,CAAC,CAAC;EACxB,GAAG;CACL;CAEA,MAAM,YAAY,IAAIC,oCAAe,IAAI,aAAa;CACtD,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;OAE9B,UAAU,OAAO;CAErB,CAAC;CAED,OAAO;AACT"}
@@ -2,7 +2,6 @@ import { Signal } from "@angular/core";
2
2
  import { Store } from "@tanstack/angular-store";
3
3
  import { AnyFunction } from "@tanstack/pacer/types";
4
4
  import { Debouncer, DebouncerOptions, DebouncerState } from "@tanstack/pacer/debouncer";
5
-
6
5
  //#region src/debouncer/injectDebouncer.d.ts
7
6
  interface AngularDebouncerOptions<TFn extends AnyFunction, TSelected = {}> extends DebouncerOptions<TFn> {
8
7
  /**
@@ -2,7 +2,6 @@ import { Signal } from "@angular/core";
2
2
  import { Store } from "@tanstack/angular-store";
3
3
  import { Debouncer, DebouncerOptions, DebouncerState } from "@tanstack/pacer/debouncer";
4
4
  import { AnyFunction } from "@tanstack/pacer/types";
5
-
6
5
  //#region src/debouncer/injectDebouncer.d.ts
7
6
  interface AngularDebouncerOptions<TFn extends AnyFunction, TSelected = {}> extends DebouncerOptions<TFn> {
8
7
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"injectDebouncer.js","names":[],"sources":["../../src/debouncer/injectDebouncer.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { Debouncer } from '@tanstack/pacer/debouncer'\nimport { injectPacerOptions } from '../provider/pacer-context'\nimport type { Signal } from '@angular/core'\nimport type { Store } from '@tanstack/angular-store'\nimport type { AnyFunction } from '@tanstack/pacer/types'\nimport type {\n DebouncerOptions,\n DebouncerState,\n} from '@tanstack/pacer/debouncer'\n\nexport interface AngularDebouncerOptions<\n TFn extends AnyFunction,\n TSelected = {},\n> extends DebouncerOptions<TFn> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the debouncer instance.\n * When provided, replaces the default cleanup (cancel); use it to call flush(), cancel(), add logging, etc.\n */\n onUnmount?: (debouncer: AngularDebouncer<TFn, TSelected>) => void\n}\n\nexport interface AngularDebouncer<\n TFn extends AnyFunction,\n TSelected = {},\n> extends Omit<Debouncer<TFn>, 'store'> {\n /**\n * Reactive state signal that will be updated when the debouncer state changes\n *\n * Use this instead of `debouncer.store.state`\n */\n readonly state: Signal<Readonly<TSelected>>\n /**\n * @deprecated Use `debouncer.state` instead of `debouncer.store.state` if you want to read reactive state.\n * The state on the store object is not reactive in Angular signals.\n */\n readonly store: Store<Readonly<DebouncerState<TFn>>>\n}\n\n/**\n * An Angular function that creates and manages a Debouncer instance.\n *\n * This is a lower-level function that provides direct access to the Debouncer's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * This function provides debouncing functionality to limit how often a function can be called,\n * waiting for a specified delay before executing the latest call. This is useful for handling\n * frequent events like window resizing, scroll events, or real-time search inputs.\n *\n * The debouncer will only execute the function after the specified wait time has elapsed\n * since the last call. If the function is called again before the wait time expires, the\n * timer resets and starts waiting again.\n *\n * ## State Management and Selector\n *\n * The function uses TanStack Store for state management and wraps it with Angular signals.\n * The `selector` parameter allows you to specify which state changes will trigger signal updates,\n * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.\n *\n * **By default, there will be no reactive state subscriptions** and you must opt-in to state\n * tracking by providing a selector function. This prevents unnecessary updates and gives you\n * full control over when your component tracks state changes.\n *\n * Available state properties:\n * - `canLeadingExecute`: Whether the debouncer can execute on the leading edge\n * - `executionCount`: Number of function executions that have been completed\n * - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution\n * - `lastArgs`: The arguments from the most recent call to maybeExecute\n * - `status`: Current execution status ('disabled' | 'idle' | 'pending')\n *\n * ## Cleanup on Destroy\n *\n * By default, the function cancels any pending execution when the component is destroyed.\n * Use the `onUnmount` option to customize this. For example, to flush pending work instead:\n *\n * ```ts\n * const debouncer = injectDebouncer(fn, {\n * wait: 500,\n * onUnmount: (d) => d.flush()\n * });\n * ```\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const debouncer = injectDebouncer(\n * (query: string) => fetchSearchResults(query),\n * { wait: 500 }\n * );\n *\n * // Opt-in to track isPending changes (optimized for loading states)\n * const debouncer = injectDebouncer(\n * (query: string) => fetchSearchResults(query),\n * { wait: 500 },\n * (state) => ({ isPending: state.isPending })\n * );\n *\n * // In an event handler\n * const handleChange = (e: Event) => {\n * const target = e.target as HTMLInputElement\n * debouncer.maybeExecute(target.value);\n * };\n *\n * // Access the selected state (will be empty object {} unless selector provided)\n * const { isPending } = debouncer.state();\n * ```\n */\nexport function injectDebouncer<TFn extends AnyFunction, TSelected = {}>(\n fn: TFn,\n options: AngularDebouncerOptions<TFn, TSelected>,\n selector: (state: DebouncerState<TFn>) => TSelected = () => ({}) as TSelected,\n): AngularDebouncer<TFn, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().debouncer,\n ...options,\n } as AngularDebouncerOptions<TFn, TSelected>\n\n const debouncer = new Debouncer<TFn>(fn, mergedOptions)\n const state = injectSelector(debouncer.store, selector)\n\n const result = {\n ...debouncer,\n state,\n } as AngularDebouncer<TFn, TSelected>\n\n const destroyRef = inject(DestroyRef, { optional: true })\n destroyRef?.onDestroy(() => {\n if (mergedOptions.onUnmount) {\n mergedOptions.onUnmount(result)\n } else {\n debouncer.cancel()\n }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4GA,SAAgB,gBACd,IACA,SACA,kBAA6D,EAAE,GAC7B;CAClC,MAAM,gBAAgB;EACpB,GAAG,oBAAoB,CAAC;EACxB,GAAG;EACJ;CAED,MAAM,YAAY,IAAI,UAAe,IAAI,cAAc;CACvD,MAAM,QAAQ,eAAe,UAAU,OAAO,SAAS;CAEvD,MAAM,SAAS;EACb,GAAG;EACH;EACD;AAGD,CADmB,OAAO,YAAY,EAAE,UAAU,MAAM,CAAC,EAC7C,gBAAgB;AAC1B,MAAI,cAAc,UAChB,eAAc,UAAU,OAAO;MAE/B,WAAU,QAAQ;GAEpB;AAEF,QAAO"}
1
+ {"version":3,"file":"injectDebouncer.js","names":[],"sources":["../../src/debouncer/injectDebouncer.ts"],"sourcesContent":["import { DestroyRef, inject } from '@angular/core'\nimport { injectSelector } from '@tanstack/angular-store'\nimport { Debouncer } from '@tanstack/pacer/debouncer'\nimport { injectPacerOptions } from '../provider/pacer-context'\nimport type { Signal } from '@angular/core'\nimport type { Store } from '@tanstack/angular-store'\nimport type { AnyFunction } from '@tanstack/pacer/types'\nimport type {\n DebouncerOptions,\n DebouncerState,\n} from '@tanstack/pacer/debouncer'\n\nexport interface AngularDebouncerOptions<\n TFn extends AnyFunction,\n TSelected = {},\n> extends DebouncerOptions<TFn> {\n /**\n * Optional callback invoked when the component is destroyed. Receives the debouncer instance.\n * When provided, replaces the default cleanup (cancel); use it to call flush(), cancel(), add logging, etc.\n */\n onUnmount?: (debouncer: AngularDebouncer<TFn, TSelected>) => void\n}\n\nexport interface AngularDebouncer<\n TFn extends AnyFunction,\n TSelected = {},\n> extends Omit<Debouncer<TFn>, 'store'> {\n /**\n * Reactive state signal that will be updated when the debouncer state changes\n *\n * Use this instead of `debouncer.store.state`\n */\n readonly state: Signal<Readonly<TSelected>>\n /**\n * @deprecated Use `debouncer.state` instead of `debouncer.store.state` if you want to read reactive state.\n * The state on the store object is not reactive in Angular signals.\n */\n readonly store: Store<Readonly<DebouncerState<TFn>>>\n}\n\n/**\n * An Angular function that creates and manages a Debouncer instance.\n *\n * This is a lower-level function that provides direct access to the Debouncer's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * This function provides debouncing functionality to limit how often a function can be called,\n * waiting for a specified delay before executing the latest call. This is useful for handling\n * frequent events like window resizing, scroll events, or real-time search inputs.\n *\n * The debouncer will only execute the function after the specified wait time has elapsed\n * since the last call. If the function is called again before the wait time expires, the\n * timer resets and starts waiting again.\n *\n * ## State Management and Selector\n *\n * The function uses TanStack Store for state management and wraps it with Angular signals.\n * The `selector` parameter allows you to specify which state changes will trigger signal updates,\n * optimizing performance by preventing unnecessary updates when irrelevant state changes occur.\n *\n * **By default, there will be no reactive state subscriptions** and you must opt-in to state\n * tracking by providing a selector function. This prevents unnecessary updates and gives you\n * full control over when your component tracks state changes.\n *\n * Available state properties:\n * - `canLeadingExecute`: Whether the debouncer can execute on the leading edge\n * - `executionCount`: Number of function executions that have been completed\n * - `isPending`: Whether the debouncer is waiting for the timeout to trigger execution\n * - `lastArgs`: The arguments from the most recent call to maybeExecute\n * - `status`: Current execution status ('disabled' | 'idle' | 'pending')\n *\n * ## Cleanup on Destroy\n *\n * By default, the function cancels any pending execution when the component is destroyed.\n * Use the `onUnmount` option to customize this. For example, to flush pending work instead:\n *\n * ```ts\n * const debouncer = injectDebouncer(fn, {\n * wait: 500,\n * onUnmount: (d) => d.flush()\n * });\n * ```\n *\n * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const debouncer = injectDebouncer(\n * (query: string) => fetchSearchResults(query),\n * { wait: 500 }\n * );\n *\n * // Opt-in to track isPending changes (optimized for loading states)\n * const debouncer = injectDebouncer(\n * (query: string) => fetchSearchResults(query),\n * { wait: 500 },\n * (state) => ({ isPending: state.isPending })\n * );\n *\n * // In an event handler\n * const handleChange = (e: Event) => {\n * const target = e.target as HTMLInputElement\n * debouncer.maybeExecute(target.value);\n * };\n *\n * // Access the selected state (will be empty object {} unless selector provided)\n * const { isPending } = debouncer.state();\n * ```\n */\nexport function injectDebouncer<TFn extends AnyFunction, TSelected = {}>(\n fn: TFn,\n options: AngularDebouncerOptions<TFn, TSelected>,\n selector: (state: DebouncerState<TFn>) => TSelected = () => ({}) as TSelected,\n): AngularDebouncer<TFn, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().debouncer,\n ...options,\n } as AngularDebouncerOptions<TFn, TSelected>\n\n const debouncer = new Debouncer<TFn>(fn, mergedOptions)\n const state = injectSelector(debouncer.store, selector)\n\n const result = {\n ...debouncer,\n state,\n } as AngularDebouncer<TFn, TSelected>\n\n const destroyRef = inject(DestroyRef, { optional: true })\n destroyRef?.onDestroy(() => {\n if (mergedOptions.onUnmount) {\n mergedOptions.onUnmount(result)\n } else {\n debouncer.cancel()\n }\n })\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4GA,SAAgB,gBACd,IACA,SACA,kBAA6D,CAAC,IAC5B;CAClC,MAAM,gBAAgB;EACpB,GAAG,mBAAmB,CAAC,CAAC;EACxB,GAAG;CACL;CAEA,MAAM,YAAY,IAAI,UAAe,IAAI,aAAa;CACtD,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;OAE9B,UAAU,OAAO;CAErB,CAAC;CAED,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"pacer-context.cjs","names":["InjectionToken"],"sources":["../../src/provider/pacer-context.ts"],"sourcesContent":["import { InjectionToken, inject } from '@angular/core'\nimport type {\n AnyAsyncFunction,\n AnyFunction,\n AsyncBatcherOptions,\n AsyncDebouncerOptions,\n AsyncQueuerOptions,\n AsyncRateLimiterOptions,\n AsyncThrottlerOptions,\n BatcherOptions,\n DebouncerOptions,\n QueuerOptions,\n RateLimiterOptions,\n ThrottlerOptions,\n} from '@tanstack/pacer'\n\nexport interface PacerProviderOptions {\n asyncBatcher?: Partial<AsyncBatcherOptions<any>>\n asyncDebouncer?: Partial<AsyncDebouncerOptions<AnyAsyncFunction>>\n asyncQueuer?: Partial<AsyncQueuerOptions<any>>\n asyncRateLimiter?: Partial<AsyncRateLimiterOptions<AnyAsyncFunction>>\n asyncThrottler?: Partial<AsyncThrottlerOptions<AnyAsyncFunction>>\n batcher?: Partial<BatcherOptions<any>>\n debouncer?: Partial<DebouncerOptions<AnyFunction>>\n queuer?: Partial<QueuerOptions<any>>\n rateLimiter?: Partial<RateLimiterOptions<AnyFunction>>\n throttler?: Partial<ThrottlerOptions<AnyFunction>>\n}\n\nconst DEFAULT_OPTIONS: PacerProviderOptions = {}\n\nexport const PACER_OPTIONS = new InjectionToken<PacerProviderOptions>(\n 'PACER_OPTIONS',\n {\n providedIn: 'root',\n factory: () => DEFAULT_OPTIONS,\n },\n)\n\nexport function injectPacerOptions(): PacerProviderOptions {\n try {\n return inject(PACER_OPTIONS, { optional: true }) ?? DEFAULT_OPTIONS\n } catch {\n return DEFAULT_OPTIONS\n }\n}\n"],"mappings":";;;AA6BA,MAAM,kBAAwC,EAAE;AAEhD,MAAa,gBAAgB,IAAIA,6BAC/B,iBACA;CACE,YAAY;CACZ,eAAe;CAChB,CACF;AAED,SAAgB,qBAA2C;AACzD,KAAI;AACF,mCAAc,eAAe,EAAE,UAAU,MAAM,CAAC,IAAI;SAC9C;AACN,SAAO"}
1
+ {"version":3,"file":"pacer-context.cjs","names":["InjectionToken","inject"],"sources":["../../src/provider/pacer-context.ts"],"sourcesContent":["import { InjectionToken, inject } from '@angular/core'\nimport type {\n AnyAsyncFunction,\n AnyFunction,\n AsyncBatcherOptions,\n AsyncDebouncerOptions,\n AsyncQueuerOptions,\n AsyncRateLimiterOptions,\n AsyncThrottlerOptions,\n BatcherOptions,\n DebouncerOptions,\n QueuerOptions,\n RateLimiterOptions,\n ThrottlerOptions,\n} from '@tanstack/pacer'\n\nexport interface PacerProviderOptions {\n asyncBatcher?: Partial<AsyncBatcherOptions<any>>\n asyncDebouncer?: Partial<AsyncDebouncerOptions<AnyAsyncFunction>>\n asyncQueuer?: Partial<AsyncQueuerOptions<any>>\n asyncRateLimiter?: Partial<AsyncRateLimiterOptions<AnyAsyncFunction>>\n asyncThrottler?: Partial<AsyncThrottlerOptions<AnyAsyncFunction>>\n batcher?: Partial<BatcherOptions<any>>\n debouncer?: Partial<DebouncerOptions<AnyFunction>>\n queuer?: Partial<QueuerOptions<any>>\n rateLimiter?: Partial<RateLimiterOptions<AnyFunction>>\n throttler?: Partial<ThrottlerOptions<AnyFunction>>\n}\n\nconst DEFAULT_OPTIONS: PacerProviderOptions = {}\n\nexport const PACER_OPTIONS = new InjectionToken<PacerProviderOptions>(\n 'PACER_OPTIONS',\n {\n providedIn: 'root',\n factory: () => DEFAULT_OPTIONS,\n },\n)\n\nexport function injectPacerOptions(): PacerProviderOptions {\n try {\n return inject(PACER_OPTIONS, { optional: true }) ?? DEFAULT_OPTIONS\n } catch {\n return DEFAULT_OPTIONS\n }\n}\n"],"mappings":";;;AA6BA,MAAM,kBAAwC,CAAC;AAE/C,MAAa,gBAAgB,IAAIA,6BAC/B,iBACA;CACE,YAAY;CACZ,eAAe;AACjB,CACF;AAEA,SAAgB,qBAA2C;CACzD,IAAI;EACF,WAAOC,sBAAO,eAAe,EAAE,UAAU,KAAK,CAAC,KAAK;CACtD,QAAQ;EACN,OAAO;CACT;AACF"}
@@ -1,6 +1,5 @@
1
1
  import { InjectionToken } from "@angular/core";
2
2
  import { AnyAsyncFunction, AnyFunction, AsyncBatcherOptions, AsyncDebouncerOptions, AsyncQueuerOptions, AsyncRateLimiterOptions, AsyncThrottlerOptions, BatcherOptions, DebouncerOptions, QueuerOptions, RateLimiterOptions, ThrottlerOptions } from "@tanstack/pacer";
3
-
4
3
  //#region src/provider/pacer-context.d.ts
5
4
  interface PacerProviderOptions {
6
5
  asyncBatcher?: Partial<AsyncBatcherOptions<any>>;
@@ -1,6 +1,5 @@
1
1
  import { AnyAsyncFunction, AnyFunction, AsyncBatcherOptions, AsyncDebouncerOptions, AsyncQueuerOptions, AsyncRateLimiterOptions, AsyncThrottlerOptions, BatcherOptions, DebouncerOptions, QueuerOptions, RateLimiterOptions, ThrottlerOptions } from "@tanstack/pacer";
2
2
  import { InjectionToken } from "@angular/core";
3
-
4
3
  //#region src/provider/pacer-context.d.ts
5
4
  interface PacerProviderOptions {
6
5
  asyncBatcher?: Partial<AsyncBatcherOptions<any>>;
@@ -1 +1 @@
1
- {"version":3,"file":"pacer-context.js","names":[],"sources":["../../src/provider/pacer-context.ts"],"sourcesContent":["import { InjectionToken, inject } from '@angular/core'\nimport type {\n AnyAsyncFunction,\n AnyFunction,\n AsyncBatcherOptions,\n AsyncDebouncerOptions,\n AsyncQueuerOptions,\n AsyncRateLimiterOptions,\n AsyncThrottlerOptions,\n BatcherOptions,\n DebouncerOptions,\n QueuerOptions,\n RateLimiterOptions,\n ThrottlerOptions,\n} from '@tanstack/pacer'\n\nexport interface PacerProviderOptions {\n asyncBatcher?: Partial<AsyncBatcherOptions<any>>\n asyncDebouncer?: Partial<AsyncDebouncerOptions<AnyAsyncFunction>>\n asyncQueuer?: Partial<AsyncQueuerOptions<any>>\n asyncRateLimiter?: Partial<AsyncRateLimiterOptions<AnyAsyncFunction>>\n asyncThrottler?: Partial<AsyncThrottlerOptions<AnyAsyncFunction>>\n batcher?: Partial<BatcherOptions<any>>\n debouncer?: Partial<DebouncerOptions<AnyFunction>>\n queuer?: Partial<QueuerOptions<any>>\n rateLimiter?: Partial<RateLimiterOptions<AnyFunction>>\n throttler?: Partial<ThrottlerOptions<AnyFunction>>\n}\n\nconst DEFAULT_OPTIONS: PacerProviderOptions = {}\n\nexport const PACER_OPTIONS = new InjectionToken<PacerProviderOptions>(\n 'PACER_OPTIONS',\n {\n providedIn: 'root',\n factory: () => DEFAULT_OPTIONS,\n },\n)\n\nexport function injectPacerOptions(): PacerProviderOptions {\n try {\n return inject(PACER_OPTIONS, { optional: true }) ?? DEFAULT_OPTIONS\n } catch {\n return DEFAULT_OPTIONS\n }\n}\n"],"mappings":";;;AA6BA,MAAM,kBAAwC,EAAE;AAEhD,MAAa,gBAAgB,IAAI,eAC/B,iBACA;CACE,YAAY;CACZ,eAAe;CAChB,CACF;AAED,SAAgB,qBAA2C;AACzD,KAAI;AACF,SAAO,OAAO,eAAe,EAAE,UAAU,MAAM,CAAC,IAAI;SAC9C;AACN,SAAO"}
1
+ {"version":3,"file":"pacer-context.js","names":[],"sources":["../../src/provider/pacer-context.ts"],"sourcesContent":["import { InjectionToken, inject } from '@angular/core'\nimport type {\n AnyAsyncFunction,\n AnyFunction,\n AsyncBatcherOptions,\n AsyncDebouncerOptions,\n AsyncQueuerOptions,\n AsyncRateLimiterOptions,\n AsyncThrottlerOptions,\n BatcherOptions,\n DebouncerOptions,\n QueuerOptions,\n RateLimiterOptions,\n ThrottlerOptions,\n} from '@tanstack/pacer'\n\nexport interface PacerProviderOptions {\n asyncBatcher?: Partial<AsyncBatcherOptions<any>>\n asyncDebouncer?: Partial<AsyncDebouncerOptions<AnyAsyncFunction>>\n asyncQueuer?: Partial<AsyncQueuerOptions<any>>\n asyncRateLimiter?: Partial<AsyncRateLimiterOptions<AnyAsyncFunction>>\n asyncThrottler?: Partial<AsyncThrottlerOptions<AnyAsyncFunction>>\n batcher?: Partial<BatcherOptions<any>>\n debouncer?: Partial<DebouncerOptions<AnyFunction>>\n queuer?: Partial<QueuerOptions<any>>\n rateLimiter?: Partial<RateLimiterOptions<AnyFunction>>\n throttler?: Partial<ThrottlerOptions<AnyFunction>>\n}\n\nconst DEFAULT_OPTIONS: PacerProviderOptions = {}\n\nexport const PACER_OPTIONS = new InjectionToken<PacerProviderOptions>(\n 'PACER_OPTIONS',\n {\n providedIn: 'root',\n factory: () => DEFAULT_OPTIONS,\n },\n)\n\nexport function injectPacerOptions(): PacerProviderOptions {\n try {\n return inject(PACER_OPTIONS, { optional: true }) ?? DEFAULT_OPTIONS\n } catch {\n return DEFAULT_OPTIONS\n }\n}\n"],"mappings":";;;AA6BA,MAAM,kBAAwC,CAAC;AAE/C,MAAa,gBAAgB,IAAI,eAC/B,iBACA;CACE,YAAY;CACZ,eAAe;AACjB,CACF;AAEA,SAAgB,qBAA2C;CACzD,IAAI;EACF,OAAO,OAAO,eAAe,EAAE,UAAU,KAAK,CAAC,KAAK;CACtD,QAAQ;EACN,OAAO;CACT;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"pacer-provider.cjs","names":["PACER_OPTIONS"],"sources":["../../src/provider/pacer-provider.ts"],"sourcesContent":["import { PACER_OPTIONS } from './pacer-context'\nimport type { Provider } from '@angular/core'\nimport type { PacerProviderOptions } from './pacer-context'\n\n/**\n * Provides default options for all Pacer utilities in the Angular application.\n * Use this function when configuring your Angular application to set default options\n * that will be used by all Pacer utilities throughout your app.\n *\n * @example\n * ```ts\n * // In your app.config.ts (standalone)\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * providePacerOptions({\n * debouncer: { wait: 300 },\n * throttler: { wait: 100 },\n * }),\n * ],\n * };\n *\n * // Or in NgModule (module-based)\n * @NgModule({\n * providers: [\n * providePacerOptions({\n * debouncer: { wait: 300 },\n * }),\n * ],\n * })\n * export class AppModule {}\n * ```\n */\nexport function providePacerOptions(options: PacerProviderOptions): Provider {\n return {\n provide: PACER_OPTIONS,\n useValue: options,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,SAAgB,oBAAoB,SAAyC;AAC3E,QAAO;EACL,SAASA;EACT,UAAU;EACX"}
1
+ {"version":3,"file":"pacer-provider.cjs","names":["PACER_OPTIONS"],"sources":["../../src/provider/pacer-provider.ts"],"sourcesContent":["import { PACER_OPTIONS } from './pacer-context'\nimport type { Provider } from '@angular/core'\nimport type { PacerProviderOptions } from './pacer-context'\n\n/**\n * Provides default options for all Pacer utilities in the Angular application.\n * Use this function when configuring your Angular application to set default options\n * that will be used by all Pacer utilities throughout your app.\n *\n * @example\n * ```ts\n * // In your app.config.ts (standalone)\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * providePacerOptions({\n * debouncer: { wait: 300 },\n * throttler: { wait: 100 },\n * }),\n * ],\n * };\n *\n * // Or in NgModule (module-based)\n * @NgModule({\n * providers: [\n * providePacerOptions({\n * debouncer: { wait: 300 },\n * }),\n * ],\n * })\n * export class AppModule {}\n * ```\n */\nexport function providePacerOptions(options: PacerProviderOptions): Provider {\n return {\n provide: PACER_OPTIONS,\n useValue: options,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,SAAgB,oBAAoB,SAAyC;CAC3E,OAAO;EACL,SAASA;EACT,UAAU;CACZ;AACF"}
@@ -1,6 +1,5 @@
1
1
  import { PacerProviderOptions } from "./pacer-context.cjs";
2
2
  import { Provider } from "@angular/core";
3
-
4
3
  //#region src/provider/pacer-provider.d.ts
5
4
  /**
6
5
  * Provides default options for all Pacer utilities in the Angular application.
@@ -1,6 +1,5 @@
1
1
  import { PacerProviderOptions } from "./pacer-context.js";
2
2
  import { Provider } from "@angular/core";
3
-
4
3
  //#region src/provider/pacer-provider.d.ts
5
4
  /**
6
5
  * Provides default options for all Pacer utilities in the Angular application.
@@ -1 +1 @@
1
- {"version":3,"file":"pacer-provider.js","names":[],"sources":["../../src/provider/pacer-provider.ts"],"sourcesContent":["import { PACER_OPTIONS } from './pacer-context'\nimport type { Provider } from '@angular/core'\nimport type { PacerProviderOptions } from './pacer-context'\n\n/**\n * Provides default options for all Pacer utilities in the Angular application.\n * Use this function when configuring your Angular application to set default options\n * that will be used by all Pacer utilities throughout your app.\n *\n * @example\n * ```ts\n * // In your app.config.ts (standalone)\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * providePacerOptions({\n * debouncer: { wait: 300 },\n * throttler: { wait: 100 },\n * }),\n * ],\n * };\n *\n * // Or in NgModule (module-based)\n * @NgModule({\n * providers: [\n * providePacerOptions({\n * debouncer: { wait: 300 },\n * }),\n * ],\n * })\n * export class AppModule {}\n * ```\n */\nexport function providePacerOptions(options: PacerProviderOptions): Provider {\n return {\n provide: PACER_OPTIONS,\n useValue: options,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,SAAgB,oBAAoB,SAAyC;AAC3E,QAAO;EACL,SAAS;EACT,UAAU;EACX"}
1
+ {"version":3,"file":"pacer-provider.js","names":[],"sources":["../../src/provider/pacer-provider.ts"],"sourcesContent":["import { PACER_OPTIONS } from './pacer-context'\nimport type { Provider } from '@angular/core'\nimport type { PacerProviderOptions } from './pacer-context'\n\n/**\n * Provides default options for all Pacer utilities in the Angular application.\n * Use this function when configuring your Angular application to set default options\n * that will be used by all Pacer utilities throughout your app.\n *\n * @example\n * ```ts\n * // In your app.config.ts (standalone)\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * providePacerOptions({\n * debouncer: { wait: 300 },\n * throttler: { wait: 100 },\n * }),\n * ],\n * };\n *\n * // Or in NgModule (module-based)\n * @NgModule({\n * providers: [\n * providePacerOptions({\n * debouncer: { wait: 300 },\n * }),\n * ],\n * })\n * export class AppModule {}\n * ```\n */\nexport function providePacerOptions(options: PacerProviderOptions): Provider {\n return {\n provide: PACER_OPTIONS,\n useValue: options,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,SAAgB,oBAAoB,SAAyC;CAC3E,OAAO;EACL,SAAS;EACT,UAAU;CACZ;AACF"}