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