@tanstack/angular-pacer 0.20.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 +165 -0
- package/dist/async-batcher/index.cjs +13 -0
- package/dist/async-batcher/index.d.cts +4 -0
- package/dist/async-batcher/index.d.ts +4 -0
- package/dist/async-batcher/index.js +6 -0
- package/dist/async-batcher/injectAsyncBatchedCallback.cjs +49 -0
- package/dist/async-batcher/injectAsyncBatchedCallback.cjs.map +1 -0
- package/dist/async-batcher/injectAsyncBatchedCallback.d.cts +45 -0
- package/dist/async-batcher/injectAsyncBatchedCallback.d.ts +45 -0
- package/dist/async-batcher/injectAsyncBatchedCallback.js +49 -0
- package/dist/async-batcher/injectAsyncBatchedCallback.js.map +1 -0
- package/dist/async-batcher/injectAsyncBatcher.cjs +61 -0
- package/dist/async-batcher/injectAsyncBatcher.cjs.map +1 -0
- package/dist/async-batcher/injectAsyncBatcher.d.cts +63 -0
- package/dist/async-batcher/injectAsyncBatcher.d.ts +63 -0
- package/dist/async-batcher/injectAsyncBatcher.js +61 -0
- package/dist/async-batcher/injectAsyncBatcher.js.map +1 -0
- package/dist/async-debouncer/index.cjs +13 -0
- package/dist/async-debouncer/index.d.cts +4 -0
- package/dist/async-debouncer/index.d.ts +4 -0
- package/dist/async-debouncer/index.js +6 -0
- package/dist/async-debouncer/injectAsyncDebouncedCallback.cjs +49 -0
- package/dist/async-debouncer/injectAsyncDebouncedCallback.cjs.map +1 -0
- package/dist/async-debouncer/injectAsyncDebouncedCallback.d.cts +43 -0
- package/dist/async-debouncer/injectAsyncDebouncedCallback.d.ts +43 -0
- package/dist/async-debouncer/injectAsyncDebouncedCallback.js +49 -0
- package/dist/async-debouncer/injectAsyncDebouncedCallback.js.map +1 -0
- package/dist/async-debouncer/injectAsyncDebouncer.cjs +83 -0
- package/dist/async-debouncer/injectAsyncDebouncer.cjs.map +1 -0
- package/dist/async-debouncer/injectAsyncDebouncer.d.cts +86 -0
- package/dist/async-debouncer/injectAsyncDebouncer.d.ts +86 -0
- package/dist/async-debouncer/injectAsyncDebouncer.js +83 -0
- package/dist/async-debouncer/injectAsyncDebouncer.js.map +1 -0
- package/dist/async-queuer/index.cjs +13 -0
- package/dist/async-queuer/index.d.cts +4 -0
- package/dist/async-queuer/index.d.ts +4 -0
- package/dist/async-queuer/index.js +6 -0
- package/dist/async-queuer/injectAsyncQueuedSignal.cjs +53 -0
- package/dist/async-queuer/injectAsyncQueuedSignal.cjs.map +1 -0
- package/dist/async-queuer/injectAsyncQueuedSignal.d.cts +55 -0
- package/dist/async-queuer/injectAsyncQueuedSignal.d.ts +55 -0
- package/dist/async-queuer/injectAsyncQueuedSignal.js +53 -0
- package/dist/async-queuer/injectAsyncQueuedSignal.js.map +1 -0
- package/dist/async-queuer/injectAsyncQueuer.cjs +61 -0
- package/dist/async-queuer/injectAsyncQueuer.cjs.map +1 -0
- package/dist/async-queuer/injectAsyncQueuer.d.cts +63 -0
- package/dist/async-queuer/injectAsyncQueuer.d.ts +63 -0
- package/dist/async-queuer/injectAsyncQueuer.js +61 -0
- package/dist/async-queuer/injectAsyncQueuer.js.map +1 -0
- package/dist/async-rate-limiter/index.cjs +13 -0
- package/dist/async-rate-limiter/index.d.cts +4 -0
- package/dist/async-rate-limiter/index.d.ts +4 -0
- package/dist/async-rate-limiter/index.js +6 -0
- package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.cjs +52 -0
- package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.cjs.map +1 -0
- package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.d.cts +46 -0
- package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.d.ts +46 -0
- package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.js +52 -0
- package/dist/async-rate-limiter/injectAsyncRateLimitedCallback.js.map +1 -0
- package/dist/async-rate-limiter/injectAsyncRateLimiter.cjs +57 -0
- package/dist/async-rate-limiter/injectAsyncRateLimiter.cjs.map +1 -0
- package/dist/async-rate-limiter/injectAsyncRateLimiter.d.cts +60 -0
- package/dist/async-rate-limiter/injectAsyncRateLimiter.d.ts +60 -0
- package/dist/async-rate-limiter/injectAsyncRateLimiter.js +57 -0
- package/dist/async-rate-limiter/injectAsyncRateLimiter.js.map +1 -0
- package/dist/async-retryer/index.cjs +9 -0
- package/dist/async-retryer/index.d.cts +1 -0
- package/dist/async-retryer/index.d.ts +1 -0
- package/dist/async-retryer/index.js +3 -0
- package/dist/async-throttler/index.cjs +13 -0
- package/dist/async-throttler/index.d.cts +4 -0
- package/dist/async-throttler/index.d.ts +4 -0
- package/dist/async-throttler/index.js +6 -0
- package/dist/async-throttler/injectAsyncThrottledCallback.cjs +50 -0
- package/dist/async-throttler/injectAsyncThrottledCallback.cjs.map +1 -0
- package/dist/async-throttler/injectAsyncThrottledCallback.d.cts +44 -0
- package/dist/async-throttler/injectAsyncThrottledCallback.d.ts +44 -0
- package/dist/async-throttler/injectAsyncThrottledCallback.js +50 -0
- package/dist/async-throttler/injectAsyncThrottledCallback.js.map +1 -0
- package/dist/async-throttler/injectAsyncThrottler.cjs +62 -0
- package/dist/async-throttler/injectAsyncThrottler.cjs.map +1 -0
- package/dist/async-throttler/injectAsyncThrottler.d.cts +65 -0
- package/dist/async-throttler/injectAsyncThrottler.d.ts +65 -0
- package/dist/async-throttler/injectAsyncThrottler.js +62 -0
- package/dist/async-throttler/injectAsyncThrottler.js.map +1 -0
- package/dist/batcher/index.cjs +13 -0
- package/dist/batcher/index.d.cts +4 -0
- package/dist/batcher/index.d.ts +4 -0
- package/dist/batcher/index.js +6 -0
- package/dist/batcher/injectBatchedCallback.cjs +47 -0
- package/dist/batcher/injectBatchedCallback.cjs.map +1 -0
- package/dist/batcher/injectBatchedCallback.d.cts +43 -0
- package/dist/batcher/injectBatchedCallback.d.ts +43 -0
- package/dist/batcher/injectBatchedCallback.js +47 -0
- package/dist/batcher/injectBatchedCallback.js.map +1 -0
- package/dist/batcher/injectBatcher.cjs +56 -0
- package/dist/batcher/injectBatcher.cjs.map +1 -0
- package/dist/batcher/injectBatcher.d.cts +58 -0
- package/dist/batcher/injectBatcher.d.ts +58 -0
- package/dist/batcher/injectBatcher.js +56 -0
- package/dist/batcher/injectBatcher.js.map +1 -0
- package/dist/debouncer/index.cjs +17 -0
- package/dist/debouncer/index.d.cts +6 -0
- package/dist/debouncer/index.d.ts +6 -0
- package/dist/debouncer/index.js +8 -0
- package/dist/debouncer/injectDebouncedCallback.cjs +46 -0
- package/dist/debouncer/injectDebouncedCallback.cjs.map +1 -0
- package/dist/debouncer/injectDebouncedCallback.d.cts +43 -0
- package/dist/debouncer/injectDebouncedCallback.d.ts +43 -0
- package/dist/debouncer/injectDebouncedCallback.js +46 -0
- package/dist/debouncer/injectDebouncedCallback.js.map +1 -0
- package/dist/debouncer/injectDebouncedSignal.cjs +68 -0
- package/dist/debouncer/injectDebouncedSignal.cjs.map +1 -0
- package/dist/debouncer/injectDebouncedSignal.d.cts +65 -0
- package/dist/debouncer/injectDebouncedSignal.d.ts +65 -0
- package/dist/debouncer/injectDebouncedSignal.js +68 -0
- package/dist/debouncer/injectDebouncedSignal.js.map +1 -0
- package/dist/debouncer/injectDebouncedValue.cjs +17 -0
- package/dist/debouncer/injectDebouncedValue.cjs.map +1 -0
- package/dist/debouncer/injectDebouncedValue.d.cts +76 -0
- package/dist/debouncer/injectDebouncedValue.d.ts +76 -0
- package/dist/debouncer/injectDebouncedValue.js +17 -0
- package/dist/debouncer/injectDebouncedValue.js.map +1 -0
- package/dist/debouncer/injectDebouncer.cjs +76 -0
- package/dist/debouncer/injectDebouncer.cjs.map +1 -0
- package/dist/debouncer/injectDebouncer.d.cts +79 -0
- package/dist/debouncer/injectDebouncer.d.ts +79 -0
- package/dist/debouncer/injectDebouncer.js +76 -0
- package/dist/debouncer/injectDebouncer.js.map +1 -0
- package/dist/index.cjs +65 -0
- package/dist/index.d.cts +30 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +32 -0
- package/dist/provider/index.cjs +7 -0
- package/dist/provider/index.d.cts +3 -0
- package/dist/provider/index.d.ts +3 -0
- package/dist/provider/index.js +4 -0
- package/dist/provider/pacer-context.cjs +20 -0
- package/dist/provider/pacer-context.cjs.map +1 -0
- package/dist/provider/pacer-context.d.cts +21 -0
- package/dist/provider/pacer-context.d.ts +21 -0
- package/dist/provider/pacer-context.js +19 -0
- package/dist/provider/pacer-context.js.map +1 -0
- package/dist/provider/pacer-provider.cjs +41 -0
- package/dist/provider/pacer-provider.cjs.map +1 -0
- package/dist/provider/pacer-provider.d.cts +36 -0
- package/dist/provider/pacer-provider.d.ts +36 -0
- package/dist/provider/pacer-provider.js +41 -0
- package/dist/provider/pacer-provider.js.map +1 -0
- package/dist/queuer/index.cjs +15 -0
- package/dist/queuer/index.d.cts +5 -0
- package/dist/queuer/index.d.ts +5 -0
- package/dist/queuer/index.js +7 -0
- package/dist/queuer/injectQueuedSignal.cjs +47 -0
- package/dist/queuer/injectQueuedSignal.cjs.map +1 -0
- package/dist/queuer/injectQueuedSignal.d.cts +49 -0
- package/dist/queuer/injectQueuedSignal.d.ts +49 -0
- package/dist/queuer/injectQueuedSignal.js +47 -0
- package/dist/queuer/injectQueuedSignal.js.map +1 -0
- package/dist/queuer/injectQueuedValue.cjs +23 -0
- package/dist/queuer/injectQueuedValue.cjs.map +1 -0
- package/dist/queuer/injectQueuedValue.d.cts +34 -0
- package/dist/queuer/injectQueuedValue.d.ts +34 -0
- package/dist/queuer/injectQueuedValue.js +23 -0
- package/dist/queuer/injectQueuedValue.js.map +1 -0
- package/dist/queuer/injectQueuer.cjs +61 -0
- package/dist/queuer/injectQueuer.cjs.map +1 -0
- package/dist/queuer/injectQueuer.d.cts +63 -0
- package/dist/queuer/injectQueuer.d.ts +63 -0
- package/dist/queuer/injectQueuer.js +61 -0
- package/dist/queuer/injectQueuer.js.map +1 -0
- package/dist/rate-limiter/index.cjs +17 -0
- package/dist/rate-limiter/index.d.cts +6 -0
- package/dist/rate-limiter/index.d.ts +6 -0
- package/dist/rate-limiter/index.js +8 -0
- package/dist/rate-limiter/injectRateLimitedCallback.cjs +45 -0
- package/dist/rate-limiter/injectRateLimitedCallback.cjs.map +1 -0
- package/dist/rate-limiter/injectRateLimitedCallback.d.cts +42 -0
- package/dist/rate-limiter/injectRateLimitedCallback.d.ts +42 -0
- package/dist/rate-limiter/injectRateLimitedCallback.js +45 -0
- package/dist/rate-limiter/injectRateLimitedCallback.js.map +1 -0
- package/dist/rate-limiter/injectRateLimitedSignal.cjs +62 -0
- package/dist/rate-limiter/injectRateLimitedSignal.cjs.map +1 -0
- package/dist/rate-limiter/injectRateLimitedSignal.d.cts +59 -0
- package/dist/rate-limiter/injectRateLimitedSignal.d.ts +59 -0
- package/dist/rate-limiter/injectRateLimitedSignal.js +62 -0
- package/dist/rate-limiter/injectRateLimitedSignal.js.map +1 -0
- package/dist/rate-limiter/injectRateLimitedValue.cjs +17 -0
- package/dist/rate-limiter/injectRateLimitedValue.cjs.map +1 -0
- package/dist/rate-limiter/injectRateLimitedValue.d.cts +49 -0
- package/dist/rate-limiter/injectRateLimitedValue.d.ts +49 -0
- package/dist/rate-limiter/injectRateLimitedValue.js +17 -0
- package/dist/rate-limiter/injectRateLimitedValue.js.map +1 -0
- package/dist/rate-limiter/injectRateLimiter.cjs +90 -0
- package/dist/rate-limiter/injectRateLimiter.cjs.map +1 -0
- package/dist/rate-limiter/injectRateLimiter.d.cts +93 -0
- package/dist/rate-limiter/injectRateLimiter.d.ts +93 -0
- package/dist/rate-limiter/injectRateLimiter.js +90 -0
- package/dist/rate-limiter/injectRateLimiter.js.map +1 -0
- package/dist/throttler/index.cjs +17 -0
- package/dist/throttler/index.d.cts +6 -0
- package/dist/throttler/index.d.ts +6 -0
- package/dist/throttler/index.js +8 -0
- package/dist/throttler/injectThrottledCallback.cjs +45 -0
- package/dist/throttler/injectThrottledCallback.cjs.map +1 -0
- package/dist/throttler/injectThrottledCallback.d.cts +42 -0
- package/dist/throttler/injectThrottledCallback.d.ts +42 -0
- package/dist/throttler/injectThrottledCallback.js +45 -0
- package/dist/throttler/injectThrottledCallback.js.map +1 -0
- package/dist/throttler/injectThrottledSignal.cjs +69 -0
- package/dist/throttler/injectThrottledSignal.cjs.map +1 -0
- package/dist/throttler/injectThrottledSignal.d.cts +66 -0
- package/dist/throttler/injectThrottledSignal.d.ts +66 -0
- package/dist/throttler/injectThrottledSignal.js +69 -0
- package/dist/throttler/injectThrottledSignal.js.map +1 -0
- package/dist/throttler/injectThrottledValue.cjs +17 -0
- package/dist/throttler/injectThrottledValue.cjs.map +1 -0
- package/dist/throttler/injectThrottledValue.d.cts +74 -0
- package/dist/throttler/injectThrottledValue.d.ts +74 -0
- package/dist/throttler/injectThrottledValue.js +17 -0
- package/dist/throttler/injectThrottledValue.js.map +1 -0
- package/dist/throttler/injectThrottler.cjs +76 -0
- package/dist/throttler/injectThrottler.cjs.map +1 -0
- package/dist/throttler/injectThrottler.d.cts +79 -0
- package/dist/throttler/injectThrottler.d.ts +79 -0
- package/dist/throttler/injectThrottler.js +76 -0
- package/dist/throttler/injectThrottler.js.map +1 -0
- package/dist/types/index.cjs +9 -0
- package/dist/types/index.d.cts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +3 -0
- package/dist/utils/index.cjs +9 -0
- package/dist/utils/index.d.cts +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +3 -0
- package/package.json +121 -0
- package/src/async-batcher/index.ts +4 -0
- package/src/async-batcher/injectAsyncBatchedCallback.ts +48 -0
- package/src/async-batcher/injectAsyncBatcher.ts +87 -0
- package/src/async-debouncer/index.ts +4 -0
- package/src/async-debouncer/injectAsyncDebouncedCallback.ts +50 -0
- package/src/async-debouncer/injectAsyncDebouncer.ts +113 -0
- package/src/async-queuer/index.ts +4 -0
- package/src/async-queuer/injectAsyncQueuedSignal.ts +82 -0
- package/src/async-queuer/injectAsyncQueuer.ts +87 -0
- package/src/async-rate-limiter/index.ts +4 -0
- package/src/async-rate-limiter/injectAsyncRateLimitedCallback.ts +52 -0
- package/src/async-rate-limiter/injectAsyncRateLimiter.ts +87 -0
- package/src/async-retryer/index.ts +1 -0
- package/src/async-throttler/index.ts +4 -0
- package/src/async-throttler/injectAsyncThrottledCallback.ts +50 -0
- package/src/async-throttler/injectAsyncThrottler.ts +92 -0
- package/src/batcher/index.ts +4 -0
- package/src/batcher/injectBatchedCallback.ts +46 -0
- package/src/batcher/injectBatcher.ts +79 -0
- package/src/debouncer/index.ts +6 -0
- package/src/debouncer/injectDebouncedCallback.ts +46 -0
- package/src/debouncer/injectDebouncedSignal.ts +101 -0
- package/src/debouncer/injectDebouncedValue.ts +126 -0
- package/src/debouncer/injectDebouncer.ts +102 -0
- package/src/index.ts +40 -0
- package/src/provider/index.ts +2 -0
- package/src/provider/pacer-context.ts +46 -0
- package/src/provider/pacer-provider.ts +38 -0
- package/src/queuer/index.ts +5 -0
- package/src/queuer/injectQueuedSignal.ts +70 -0
- package/src/queuer/injectQueuedValue.ts +101 -0
- package/src/queuer/injectQueuer.ts +83 -0
- package/src/rate-limiter/index.ts +6 -0
- package/src/rate-limiter/injectRateLimitedCallback.ts +45 -0
- package/src/rate-limiter/injectRateLimitedSignal.ts +95 -0
- package/src/rate-limiter/injectRateLimitedValue.ts +99 -0
- package/src/rate-limiter/injectRateLimiter.ts +116 -0
- package/src/throttler/index.ts +6 -0
- package/src/throttler/injectThrottledCallback.ts +45 -0
- package/src/throttler/injectThrottledSignal.ts +102 -0
- package/src/throttler/injectThrottledValue.ts +124 -0
- package/src/throttler/injectThrottler.ts +102 -0
- package/src/types/index.ts +1 -0
- package/src/utils/index.ts +1 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const require_injectQueuer = require('./injectQueuer.cjs');
|
|
2
|
+
let _angular_core = require("@angular/core");
|
|
3
|
+
|
|
4
|
+
//#region src/queuer/injectQueuedSignal.ts
|
|
5
|
+
/**
|
|
6
|
+
* An Angular function that creates a queuer with managed state, combining Angular's signals with queuing functionality.
|
|
7
|
+
* This function provides both the current queue state and queue control methods.
|
|
8
|
+
*
|
|
9
|
+
* The queue state is automatically updated whenever items are added, removed, or reordered in the queue.
|
|
10
|
+
* All queue operations are reflected in the state array returned by the function.
|
|
11
|
+
*
|
|
12
|
+
* The function returns a callable object:
|
|
13
|
+
* - `queued()`: Get the current queue items as an array
|
|
14
|
+
* - `queued.addItem(...)`: Add an item to the queue
|
|
15
|
+
* - `queued.queue`: The queuer instance with additional control methods
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* // Default behavior - track items
|
|
20
|
+
* const queued = injectQueuedSignal(
|
|
21
|
+
* (item) => console.log('Processing:', item),
|
|
22
|
+
* { started: true, wait: 1000 }
|
|
23
|
+
* );
|
|
24
|
+
*
|
|
25
|
+
* // Add items
|
|
26
|
+
* queued.addItem('task1');
|
|
27
|
+
*
|
|
28
|
+
* // Access items
|
|
29
|
+
* console.log(queued()); // ['task1']
|
|
30
|
+
*
|
|
31
|
+
* // Control the queue
|
|
32
|
+
* queued.queuer.start();
|
|
33
|
+
* queued.queuer.stop();
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
function injectQueuedSignal(fn, options = {}, selector = (state) => ({ items: state.items })) {
|
|
37
|
+
const queuer = require_injectQueuer.injectQueuer(fn, options, selector);
|
|
38
|
+
const items = (0, _angular_core.computed)(() => queuer.state().items);
|
|
39
|
+
return Object.assign(items, {
|
|
40
|
+
addItem: queuer.addItem.bind(queuer),
|
|
41
|
+
queuer
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
exports.injectQueuedSignal = injectQueuedSignal;
|
|
47
|
+
//# sourceMappingURL=injectQueuedSignal.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injectQueuedSignal.cjs","names":["injectQueuer"],"sources":["../../src/queuer/injectQueuedSignal.ts"],"sourcesContent":["import { computed } from '@angular/core'\nimport { injectQueuer } from './injectQueuer'\nimport type { AngularQueuer } from './injectQueuer'\nimport type { QueuerOptions, QueuerState } from '@tanstack/pacer/queuer'\n\nexport type QueuedSignal<TValue, TSelected = {}> = (() => Array<TValue>) & {\n /**\n * Add an item to the queue.\n */\n readonly addItem: AngularQueuer<TValue, TSelected>['addItem']\n /**\n * The queuer instance with additional control methods and state signals.\n */\n readonly queuer: AngularQueuer<TValue, TSelected>\n}\n\n/**\n * An Angular function that creates a queuer with managed state, combining Angular's signals with queuing functionality.\n * This function provides both the current queue state and queue control methods.\n *\n * The queue state is automatically updated whenever items are added, removed, or reordered in the queue.\n * All queue operations are reflected in the state array returned by the function.\n *\n * The function returns a callable object:\n * - `queued()`: Get the current queue items as an array\n * - `queued.addItem(...)`: Add an item to the queue\n * - `queued.queue`: The queuer instance with additional control methods\n *\n * @example\n * ```ts\n * // Default behavior - track items\n * const queued = injectQueuedSignal(\n * (item) => console.log('Processing:', item),\n * { started: true, wait: 1000 }\n * );\n *\n * // Add items\n * queued.addItem('task1');\n *\n * // Access items\n * console.log(queued()); // ['task1']\n *\n * // Control the queue\n * queued.queuer.start();\n * queued.queuer.stop();\n * ```\n */\nexport function injectQueuedSignal<\n TValue,\n TSelected extends Pick<QueuerState<TValue>, 'items'> = Pick<\n QueuerState<TValue>,\n 'items'\n >,\n>(\n fn: (item: TValue) => void,\n options: QueuerOptions<TValue> = {},\n selector: (state: QueuerState<TValue>) => TSelected = (state) =>\n ({ items: state.items }) as TSelected,\n): QueuedSignal<TValue, TSelected> {\n const queuer = injectQueuer(fn, options, selector)\n\n const items = computed(() => queuer.state().items as Array<TValue>)\n\n const queued = Object.assign(items, {\n addItem: queuer.addItem.bind(queuer),\n queuer,\n }) as QueuedSignal<TValue, TSelected>\n\n return queued\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,SAAgB,mBAOd,IACA,UAAiC,EAAE,EACnC,YAAuD,WACpD,EAAE,OAAO,MAAM,OAAO,GACQ;CACjC,MAAM,SAASA,kCAAa,IAAI,SAAS,SAAS;CAElD,MAAM,0CAAuB,OAAO,OAAO,CAAC,MAAuB;AAOnE,QALe,OAAO,OAAO,OAAO;EAClC,SAAS,OAAO,QAAQ,KAAK,OAAO;EACpC;EACD,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { AngularQueuer } from "./injectQueuer.cjs";
|
|
2
|
+
import { QueuerOptions, QueuerState } from "@tanstack/pacer/queuer";
|
|
3
|
+
|
|
4
|
+
//#region src/queuer/injectQueuedSignal.d.ts
|
|
5
|
+
type QueuedSignal<TValue, TSelected = {}> = (() => Array<TValue>) & {
|
|
6
|
+
/**
|
|
7
|
+
* Add an item to the queue.
|
|
8
|
+
*/
|
|
9
|
+
readonly addItem: AngularQueuer<TValue, TSelected>['addItem'];
|
|
10
|
+
/**
|
|
11
|
+
* The queuer instance with additional control methods and state signals.
|
|
12
|
+
*/
|
|
13
|
+
readonly queuer: AngularQueuer<TValue, TSelected>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* An Angular function that creates a queuer with managed state, combining Angular's signals with queuing functionality.
|
|
17
|
+
* This function provides both the current queue state and queue control methods.
|
|
18
|
+
*
|
|
19
|
+
* The queue state is automatically updated whenever items are added, removed, or reordered in the queue.
|
|
20
|
+
* All queue operations are reflected in the state array returned by the function.
|
|
21
|
+
*
|
|
22
|
+
* The function returns a callable object:
|
|
23
|
+
* - `queued()`: Get the current queue items as an array
|
|
24
|
+
* - `queued.addItem(...)`: Add an item to the queue
|
|
25
|
+
* - `queued.queue`: The queuer instance with additional control methods
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* // Default behavior - track items
|
|
30
|
+
* const queued = injectQueuedSignal(
|
|
31
|
+
* (item) => console.log('Processing:', item),
|
|
32
|
+
* { started: true, wait: 1000 }
|
|
33
|
+
* );
|
|
34
|
+
*
|
|
35
|
+
* // Add items
|
|
36
|
+
* queued.addItem('task1');
|
|
37
|
+
*
|
|
38
|
+
* // Access items
|
|
39
|
+
* console.log(queued()); // ['task1']
|
|
40
|
+
*
|
|
41
|
+
* // Control the queue
|
|
42
|
+
* queued.queuer.start();
|
|
43
|
+
* queued.queuer.stop();
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
declare function injectQueuedSignal<TValue, TSelected extends Pick<QueuerState<TValue>, 'items'> = Pick<QueuerState<TValue>, 'items'>>(fn: (item: TValue) => void, options?: QueuerOptions<TValue>, selector?: (state: QueuerState<TValue>) => TSelected): QueuedSignal<TValue, TSelected>;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { QueuedSignal, injectQueuedSignal };
|
|
49
|
+
//# sourceMappingURL=injectQueuedSignal.d.cts.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { AngularQueuer } from "./injectQueuer.js";
|
|
2
|
+
import { QueuerOptions, QueuerState } from "@tanstack/pacer/queuer";
|
|
3
|
+
|
|
4
|
+
//#region src/queuer/injectQueuedSignal.d.ts
|
|
5
|
+
type QueuedSignal<TValue, TSelected = {}> = (() => Array<TValue>) & {
|
|
6
|
+
/**
|
|
7
|
+
* Add an item to the queue.
|
|
8
|
+
*/
|
|
9
|
+
readonly addItem: AngularQueuer<TValue, TSelected>['addItem'];
|
|
10
|
+
/**
|
|
11
|
+
* The queuer instance with additional control methods and state signals.
|
|
12
|
+
*/
|
|
13
|
+
readonly queuer: AngularQueuer<TValue, TSelected>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* An Angular function that creates a queuer with managed state, combining Angular's signals with queuing functionality.
|
|
17
|
+
* This function provides both the current queue state and queue control methods.
|
|
18
|
+
*
|
|
19
|
+
* The queue state is automatically updated whenever items are added, removed, or reordered in the queue.
|
|
20
|
+
* All queue operations are reflected in the state array returned by the function.
|
|
21
|
+
*
|
|
22
|
+
* The function returns a callable object:
|
|
23
|
+
* - `queued()`: Get the current queue items as an array
|
|
24
|
+
* - `queued.addItem(...)`: Add an item to the queue
|
|
25
|
+
* - `queued.queue`: The queuer instance with additional control methods
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* // Default behavior - track items
|
|
30
|
+
* const queued = injectQueuedSignal(
|
|
31
|
+
* (item) => console.log('Processing:', item),
|
|
32
|
+
* { started: true, wait: 1000 }
|
|
33
|
+
* );
|
|
34
|
+
*
|
|
35
|
+
* // Add items
|
|
36
|
+
* queued.addItem('task1');
|
|
37
|
+
*
|
|
38
|
+
* // Access items
|
|
39
|
+
* console.log(queued()); // ['task1']
|
|
40
|
+
*
|
|
41
|
+
* // Control the queue
|
|
42
|
+
* queued.queuer.start();
|
|
43
|
+
* queued.queuer.stop();
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
declare function injectQueuedSignal<TValue, TSelected extends Pick<QueuerState<TValue>, 'items'> = Pick<QueuerState<TValue>, 'items'>>(fn: (item: TValue) => void, options?: QueuerOptions<TValue>, selector?: (state: QueuerState<TValue>) => TSelected): QueuedSignal<TValue, TSelected>;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { QueuedSignal, injectQueuedSignal };
|
|
49
|
+
//# sourceMappingURL=injectQueuedSignal.d.ts.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { injectQueuer } from "./injectQueuer.js";
|
|
2
|
+
import { computed } from "@angular/core";
|
|
3
|
+
|
|
4
|
+
//#region src/queuer/injectQueuedSignal.ts
|
|
5
|
+
/**
|
|
6
|
+
* An Angular function that creates a queuer with managed state, combining Angular's signals with queuing functionality.
|
|
7
|
+
* This function provides both the current queue state and queue control methods.
|
|
8
|
+
*
|
|
9
|
+
* The queue state is automatically updated whenever items are added, removed, or reordered in the queue.
|
|
10
|
+
* All queue operations are reflected in the state array returned by the function.
|
|
11
|
+
*
|
|
12
|
+
* The function returns a callable object:
|
|
13
|
+
* - `queued()`: Get the current queue items as an array
|
|
14
|
+
* - `queued.addItem(...)`: Add an item to the queue
|
|
15
|
+
* - `queued.queue`: The queuer instance with additional control methods
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* // Default behavior - track items
|
|
20
|
+
* const queued = injectQueuedSignal(
|
|
21
|
+
* (item) => console.log('Processing:', item),
|
|
22
|
+
* { started: true, wait: 1000 }
|
|
23
|
+
* );
|
|
24
|
+
*
|
|
25
|
+
* // Add items
|
|
26
|
+
* queued.addItem('task1');
|
|
27
|
+
*
|
|
28
|
+
* // Access items
|
|
29
|
+
* console.log(queued()); // ['task1']
|
|
30
|
+
*
|
|
31
|
+
* // Control the queue
|
|
32
|
+
* queued.queuer.start();
|
|
33
|
+
* queued.queuer.stop();
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
function injectQueuedSignal(fn, options = {}, selector = (state) => ({ items: state.items })) {
|
|
37
|
+
const queuer = injectQueuer(fn, options, selector);
|
|
38
|
+
const items = computed(() => queuer.state().items);
|
|
39
|
+
return Object.assign(items, {
|
|
40
|
+
addItem: queuer.addItem.bind(queuer),
|
|
41
|
+
queuer
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
export { injectQueuedSignal };
|
|
47
|
+
//# sourceMappingURL=injectQueuedSignal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injectQueuedSignal.js","names":[],"sources":["../../src/queuer/injectQueuedSignal.ts"],"sourcesContent":["import { computed } from '@angular/core'\nimport { injectQueuer } from './injectQueuer'\nimport type { AngularQueuer } from './injectQueuer'\nimport type { QueuerOptions, QueuerState } from '@tanstack/pacer/queuer'\n\nexport type QueuedSignal<TValue, TSelected = {}> = (() => Array<TValue>) & {\n /**\n * Add an item to the queue.\n */\n readonly addItem: AngularQueuer<TValue, TSelected>['addItem']\n /**\n * The queuer instance with additional control methods and state signals.\n */\n readonly queuer: AngularQueuer<TValue, TSelected>\n}\n\n/**\n * An Angular function that creates a queuer with managed state, combining Angular's signals with queuing functionality.\n * This function provides both the current queue state and queue control methods.\n *\n * The queue state is automatically updated whenever items are added, removed, or reordered in the queue.\n * All queue operations are reflected in the state array returned by the function.\n *\n * The function returns a callable object:\n * - `queued()`: Get the current queue items as an array\n * - `queued.addItem(...)`: Add an item to the queue\n * - `queued.queue`: The queuer instance with additional control methods\n *\n * @example\n * ```ts\n * // Default behavior - track items\n * const queued = injectQueuedSignal(\n * (item) => console.log('Processing:', item),\n * { started: true, wait: 1000 }\n * );\n *\n * // Add items\n * queued.addItem('task1');\n *\n * // Access items\n * console.log(queued()); // ['task1']\n *\n * // Control the queue\n * queued.queuer.start();\n * queued.queuer.stop();\n * ```\n */\nexport function injectQueuedSignal<\n TValue,\n TSelected extends Pick<QueuerState<TValue>, 'items'> = Pick<\n QueuerState<TValue>,\n 'items'\n >,\n>(\n fn: (item: TValue) => void,\n options: QueuerOptions<TValue> = {},\n selector: (state: QueuerState<TValue>) => TSelected = (state) =>\n ({ items: state.items }) as TSelected,\n): QueuedSignal<TValue, TSelected> {\n const queuer = injectQueuer(fn, options, selector)\n\n const items = computed(() => queuer.state().items as Array<TValue>)\n\n const queued = Object.assign(items, {\n addItem: queuer.addItem.bind(queuer),\n queuer,\n }) as QueuedSignal<TValue, TSelected>\n\n return queued\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,SAAgB,mBAOd,IACA,UAAiC,EAAE,EACnC,YAAuD,WACpD,EAAE,OAAO,MAAM,OAAO,GACQ;CACjC,MAAM,SAAS,aAAa,IAAI,SAAS,SAAS;CAElD,MAAM,QAAQ,eAAe,OAAO,OAAO,CAAC,MAAuB;AAOnE,QALe,OAAO,OAAO,OAAO;EAClC,SAAS,OAAO,QAAQ,KAAK,OAAO;EACpC;EACD,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const require_injectQueuedSignal = require('./injectQueuedSignal.cjs');
|
|
2
|
+
let _angular_core = require("@angular/core");
|
|
3
|
+
|
|
4
|
+
//#region src/queuer/injectQueuedValue.ts
|
|
5
|
+
function injectQueuedValue(value, initialValueOrOptions, initialOptionsOrSelector, maybeSelector) {
|
|
6
|
+
const hasInitialValue = initialOptionsOrSelector !== void 0 && !(typeof initialOptionsOrSelector === "function") || maybeSelector !== void 0;
|
|
7
|
+
const initialValue = hasInitialValue ? initialValueOrOptions : value();
|
|
8
|
+
const initialOptions = hasInitialValue ? initialOptionsOrSelector : initialValueOrOptions;
|
|
9
|
+
const selector = hasInitialValue ? maybeSelector : initialOptionsOrSelector;
|
|
10
|
+
const linkedValue = (0, _angular_core.linkedSignal)(() => value());
|
|
11
|
+
const queuedValue = (0, _angular_core.signal)(initialValue);
|
|
12
|
+
const queued = require_injectQueuedSignal.injectQueuedSignal((item) => {
|
|
13
|
+
queuedValue.set(item);
|
|
14
|
+
}, initialOptions, selector);
|
|
15
|
+
(0, _angular_core.effect)(() => {
|
|
16
|
+
queued.addItem(linkedValue());
|
|
17
|
+
});
|
|
18
|
+
return queued;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.injectQueuedValue = injectQueuedValue;
|
|
23
|
+
//# sourceMappingURL=injectQueuedValue.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injectQueuedValue.cjs","names":["injectQueuedSignal"],"sources":["../../src/queuer/injectQueuedValue.ts"],"sourcesContent":["import { effect, linkedSignal, signal } from '@angular/core'\nimport { injectQueuedSignal } from './injectQueuedSignal'\nimport type { QueuedSignal } from './injectQueuedSignal'\nimport type { Signal } from '@angular/core'\nimport type { QueuerOptions, QueuerState } from '@tanstack/pacer/queuer'\n\n/**\n * An Angular function that creates a queued value that processes state changes in order with an optional delay.\n * This function uses injectQueuedSignal internally to manage a queue of state changes and apply them sequentially.\n *\n * The queued value will process changes in the order they are received, with optional delays between\n * processing each change. This is useful for handling state updates that need to be processed\n * in a specific order, like animations or sequential UI updates.\n *\n * The function returns a tuple containing:\n * - A Signal that provides the current queued value\n * - The queuer instance with control methods\n *\n * @example\n * ```ts\n * const initialValue = signal('initial')\n * const queued = injectQueuedValue(initialValue, {\n * wait: 500,\n * started: true,\n * })\n *\n * // Add changes to the queue\n * queued.addItem('new value')\n * ```\n */\nexport function injectQueuedValue<\n TValue,\n TSelected extends Pick<QueuerState<TValue>, 'items'> = Pick<\n QueuerState<TValue>,\n 'items'\n >,\n>(\n value: Signal<TValue>,\n options?: QueuerOptions<TValue>,\n selector?: (state: QueuerState<TValue>) => TSelected,\n): QueuedSignal<TValue, TSelected>\nexport function injectQueuedValue<\n TValue,\n TSelected extends Pick<QueuerState<TValue>, 'items'> = Pick<\n QueuerState<TValue>,\n 'items'\n >,\n>(\n value: Signal<TValue>,\n initialValue: TValue,\n options?: QueuerOptions<TValue>,\n selector?: (state: QueuerState<TValue>) => TSelected,\n): QueuedSignal<TValue, TSelected>\nexport function injectQueuedValue<\n TValue,\n TSelected extends Pick<QueuerState<TValue>, 'items'> = Pick<\n QueuerState<TValue>,\n 'items'\n >,\n>(\n value: Signal<TValue>,\n initialValueOrOptions?: TValue | QueuerOptions<TValue>,\n initialOptionsOrSelector?:\n | QueuerOptions<TValue>\n | ((state: QueuerState<TValue>) => TSelected),\n maybeSelector?: (state: QueuerState<TValue>) => TSelected,\n): QueuedSignal<TValue, TSelected> {\n const hasSelector = typeof initialOptionsOrSelector === 'function'\n const hasInitialValue =\n (initialOptionsOrSelector !== undefined && !hasSelector) ||\n maybeSelector !== undefined\n\n const initialValue = hasInitialValue\n ? (initialValueOrOptions as TValue)\n : value()\n const initialOptions = hasInitialValue\n ? (initialOptionsOrSelector as QueuerOptions<TValue>)\n : (initialValueOrOptions as QueuerOptions<TValue>)\n const selector = hasInitialValue\n ? maybeSelector\n : (initialOptionsOrSelector as\n | ((state: QueuerState<TValue>) => TSelected)\n | undefined)\n\n const linkedValue = linkedSignal(() => value())\n const queuedValue = signal<TValue>(initialValue)\n\n const queued = injectQueuedSignal(\n (item) => {\n queuedValue.set(item)\n },\n initialOptions,\n selector,\n )\n\n effect(() => {\n queued.addItem(linkedValue())\n })\n\n return queued\n}\n"],"mappings":";;;;AAqDA,SAAgB,kBAOd,OACA,uBACA,0BAGA,eACiC;CAEjC,MAAM,kBACH,6BAA6B,UAAa,EAFzB,OAAO,6BAA6B,eAGtD,kBAAkB;CAEpB,MAAM,eAAe,kBAChB,wBACD,OAAO;CACX,MAAM,iBAAiB,kBAClB,2BACA;CACL,MAAM,WAAW,kBACb,gBACC;CAIL,MAAM,oDAAiC,OAAO,CAAC;CAC/C,MAAM,wCAA6B,aAAa;CAEhD,MAAM,SAASA,+CACZ,SAAS;AACR,cAAY,IAAI,KAAK;IAEvB,gBACA,SACD;AAED,iCAAa;AACX,SAAO,QAAQ,aAAa,CAAC;GAC7B;AAEF,QAAO"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { QueuedSignal } from "./injectQueuedSignal.cjs";
|
|
2
|
+
import { Signal } from "@angular/core";
|
|
3
|
+
import { QueuerOptions, QueuerState } from "@tanstack/pacer/queuer";
|
|
4
|
+
|
|
5
|
+
//#region src/queuer/injectQueuedValue.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* An Angular function that creates a queued value that processes state changes in order with an optional delay.
|
|
8
|
+
* This function uses injectQueuedSignal internally to manage a queue of state changes and apply them sequentially.
|
|
9
|
+
*
|
|
10
|
+
* The queued value will process changes in the order they are received, with optional delays between
|
|
11
|
+
* processing each change. This is useful for handling state updates that need to be processed
|
|
12
|
+
* in a specific order, like animations or sequential UI updates.
|
|
13
|
+
*
|
|
14
|
+
* The function returns a tuple containing:
|
|
15
|
+
* - A Signal that provides the current queued value
|
|
16
|
+
* - The queuer instance with control methods
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const initialValue = signal('initial')
|
|
21
|
+
* const queued = injectQueuedValue(initialValue, {
|
|
22
|
+
* wait: 500,
|
|
23
|
+
* started: true,
|
|
24
|
+
* })
|
|
25
|
+
*
|
|
26
|
+
* // Add changes to the queue
|
|
27
|
+
* queued.addItem('new value')
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
declare function injectQueuedValue<TValue, TSelected extends Pick<QueuerState<TValue>, 'items'> = Pick<QueuerState<TValue>, 'items'>>(value: Signal<TValue>, options?: QueuerOptions<TValue>, selector?: (state: QueuerState<TValue>) => TSelected): QueuedSignal<TValue, TSelected>;
|
|
31
|
+
declare function injectQueuedValue<TValue, TSelected extends Pick<QueuerState<TValue>, 'items'> = Pick<QueuerState<TValue>, 'items'>>(value: Signal<TValue>, initialValue: TValue, options?: QueuerOptions<TValue>, selector?: (state: QueuerState<TValue>) => TSelected): QueuedSignal<TValue, TSelected>;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { injectQueuedValue };
|
|
34
|
+
//# sourceMappingURL=injectQueuedValue.d.cts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { QueuedSignal } from "./injectQueuedSignal.js";
|
|
2
|
+
import { Signal } from "@angular/core";
|
|
3
|
+
import { QueuerOptions, QueuerState } from "@tanstack/pacer/queuer";
|
|
4
|
+
|
|
5
|
+
//#region src/queuer/injectQueuedValue.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* An Angular function that creates a queued value that processes state changes in order with an optional delay.
|
|
8
|
+
* This function uses injectQueuedSignal internally to manage a queue of state changes and apply them sequentially.
|
|
9
|
+
*
|
|
10
|
+
* The queued value will process changes in the order they are received, with optional delays between
|
|
11
|
+
* processing each change. This is useful for handling state updates that need to be processed
|
|
12
|
+
* in a specific order, like animations or sequential UI updates.
|
|
13
|
+
*
|
|
14
|
+
* The function returns a tuple containing:
|
|
15
|
+
* - A Signal that provides the current queued value
|
|
16
|
+
* - The queuer instance with control methods
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const initialValue = signal('initial')
|
|
21
|
+
* const queued = injectQueuedValue(initialValue, {
|
|
22
|
+
* wait: 500,
|
|
23
|
+
* started: true,
|
|
24
|
+
* })
|
|
25
|
+
*
|
|
26
|
+
* // Add changes to the queue
|
|
27
|
+
* queued.addItem('new value')
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
declare function injectQueuedValue<TValue, TSelected extends Pick<QueuerState<TValue>, 'items'> = Pick<QueuerState<TValue>, 'items'>>(value: Signal<TValue>, options?: QueuerOptions<TValue>, selector?: (state: QueuerState<TValue>) => TSelected): QueuedSignal<TValue, TSelected>;
|
|
31
|
+
declare function injectQueuedValue<TValue, TSelected extends Pick<QueuerState<TValue>, 'items'> = Pick<QueuerState<TValue>, 'items'>>(value: Signal<TValue>, initialValue: TValue, options?: QueuerOptions<TValue>, selector?: (state: QueuerState<TValue>) => TSelected): QueuedSignal<TValue, TSelected>;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { injectQueuedValue };
|
|
34
|
+
//# sourceMappingURL=injectQueuedValue.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { injectQueuedSignal } from "./injectQueuedSignal.js";
|
|
2
|
+
import { effect, linkedSignal, signal } from "@angular/core";
|
|
3
|
+
|
|
4
|
+
//#region src/queuer/injectQueuedValue.ts
|
|
5
|
+
function injectQueuedValue(value, initialValueOrOptions, initialOptionsOrSelector, maybeSelector) {
|
|
6
|
+
const hasInitialValue = initialOptionsOrSelector !== void 0 && !(typeof initialOptionsOrSelector === "function") || maybeSelector !== void 0;
|
|
7
|
+
const initialValue = hasInitialValue ? initialValueOrOptions : value();
|
|
8
|
+
const initialOptions = hasInitialValue ? initialOptionsOrSelector : initialValueOrOptions;
|
|
9
|
+
const selector = hasInitialValue ? maybeSelector : initialOptionsOrSelector;
|
|
10
|
+
const linkedValue = linkedSignal(() => value());
|
|
11
|
+
const queuedValue = signal(initialValue);
|
|
12
|
+
const queued = injectQueuedSignal((item) => {
|
|
13
|
+
queuedValue.set(item);
|
|
14
|
+
}, initialOptions, selector);
|
|
15
|
+
effect(() => {
|
|
16
|
+
queued.addItem(linkedValue());
|
|
17
|
+
});
|
|
18
|
+
return queued;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { injectQueuedValue };
|
|
23
|
+
//# sourceMappingURL=injectQueuedValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injectQueuedValue.js","names":[],"sources":["../../src/queuer/injectQueuedValue.ts"],"sourcesContent":["import { effect, linkedSignal, signal } from '@angular/core'\nimport { injectQueuedSignal } from './injectQueuedSignal'\nimport type { QueuedSignal } from './injectQueuedSignal'\nimport type { Signal } from '@angular/core'\nimport type { QueuerOptions, QueuerState } from '@tanstack/pacer/queuer'\n\n/**\n * An Angular function that creates a queued value that processes state changes in order with an optional delay.\n * This function uses injectQueuedSignal internally to manage a queue of state changes and apply them sequentially.\n *\n * The queued value will process changes in the order they are received, with optional delays between\n * processing each change. This is useful for handling state updates that need to be processed\n * in a specific order, like animations or sequential UI updates.\n *\n * The function returns a tuple containing:\n * - A Signal that provides the current queued value\n * - The queuer instance with control methods\n *\n * @example\n * ```ts\n * const initialValue = signal('initial')\n * const queued = injectQueuedValue(initialValue, {\n * wait: 500,\n * started: true,\n * })\n *\n * // Add changes to the queue\n * queued.addItem('new value')\n * ```\n */\nexport function injectQueuedValue<\n TValue,\n TSelected extends Pick<QueuerState<TValue>, 'items'> = Pick<\n QueuerState<TValue>,\n 'items'\n >,\n>(\n value: Signal<TValue>,\n options?: QueuerOptions<TValue>,\n selector?: (state: QueuerState<TValue>) => TSelected,\n): QueuedSignal<TValue, TSelected>\nexport function injectQueuedValue<\n TValue,\n TSelected extends Pick<QueuerState<TValue>, 'items'> = Pick<\n QueuerState<TValue>,\n 'items'\n >,\n>(\n value: Signal<TValue>,\n initialValue: TValue,\n options?: QueuerOptions<TValue>,\n selector?: (state: QueuerState<TValue>) => TSelected,\n): QueuedSignal<TValue, TSelected>\nexport function injectQueuedValue<\n TValue,\n TSelected extends Pick<QueuerState<TValue>, 'items'> = Pick<\n QueuerState<TValue>,\n 'items'\n >,\n>(\n value: Signal<TValue>,\n initialValueOrOptions?: TValue | QueuerOptions<TValue>,\n initialOptionsOrSelector?:\n | QueuerOptions<TValue>\n | ((state: QueuerState<TValue>) => TSelected),\n maybeSelector?: (state: QueuerState<TValue>) => TSelected,\n): QueuedSignal<TValue, TSelected> {\n const hasSelector = typeof initialOptionsOrSelector === 'function'\n const hasInitialValue =\n (initialOptionsOrSelector !== undefined && !hasSelector) ||\n maybeSelector !== undefined\n\n const initialValue = hasInitialValue\n ? (initialValueOrOptions as TValue)\n : value()\n const initialOptions = hasInitialValue\n ? (initialOptionsOrSelector as QueuerOptions<TValue>)\n : (initialValueOrOptions as QueuerOptions<TValue>)\n const selector = hasInitialValue\n ? maybeSelector\n : (initialOptionsOrSelector as\n | ((state: QueuerState<TValue>) => TSelected)\n | undefined)\n\n const linkedValue = linkedSignal(() => value())\n const queuedValue = signal<TValue>(initialValue)\n\n const queued = injectQueuedSignal(\n (item) => {\n queuedValue.set(item)\n },\n initialOptions,\n selector,\n )\n\n effect(() => {\n queued.addItem(linkedValue())\n })\n\n return queued\n}\n"],"mappings":";;;;AAqDA,SAAgB,kBAOd,OACA,uBACA,0BAGA,eACiC;CAEjC,MAAM,kBACH,6BAA6B,UAAa,EAFzB,OAAO,6BAA6B,eAGtD,kBAAkB;CAEpB,MAAM,eAAe,kBAChB,wBACD,OAAO;CACX,MAAM,iBAAiB,kBAClB,2BACA;CACL,MAAM,WAAW,kBACb,gBACC;CAIL,MAAM,cAAc,mBAAmB,OAAO,CAAC;CAC/C,MAAM,cAAc,OAAe,aAAa;CAEhD,MAAM,SAAS,oBACZ,SAAS;AACR,cAAY,IAAI,KAAK;IAEvB,gBACA,SACD;AAED,cAAa;AACX,SAAO,QAAQ,aAAa,CAAC;GAC7B;AAEF,QAAO"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const require_pacer_context = require('../provider/pacer-context.cjs');
|
|
2
|
+
let _tanstack_angular_store = require("@tanstack/angular-store");
|
|
3
|
+
let _tanstack_pacer_queuer = require("@tanstack/pacer/queuer");
|
|
4
|
+
|
|
5
|
+
//#region src/queuer/injectQueuer.ts
|
|
6
|
+
/**
|
|
7
|
+
* An Angular function that creates and manages a Queuer instance.
|
|
8
|
+
*
|
|
9
|
+
* This is a lower-level function that provides direct access to the Queuer's functionality.
|
|
10
|
+
* This allows you to integrate it with any state management solution you prefer.
|
|
11
|
+
*
|
|
12
|
+
* The Queuer processes items synchronously in order, with optional delays between processing each item.
|
|
13
|
+
* The queuer includes an internal tick mechanism that can be started and stopped, making it useful as a scheduler.
|
|
14
|
+
*
|
|
15
|
+
* ## State Management and Selector
|
|
16
|
+
*
|
|
17
|
+
* The function uses TanStack Store for state management and wraps it with Angular signals.
|
|
18
|
+
* The `selector` parameter allows you to specify which state changes will trigger signal updates,
|
|
19
|
+
* optimizing performance by preventing unnecessary updates when irrelevant state changes occur.
|
|
20
|
+
*
|
|
21
|
+
* **By default, there will be no reactive state subscriptions** and you must opt-in to state
|
|
22
|
+
* tracking by providing a selector function. This prevents unnecessary updates and gives you
|
|
23
|
+
* full control over when your component tracks state changes.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* // Default behavior - no reactive state subscriptions
|
|
28
|
+
* const queue = injectQueuer(
|
|
29
|
+
* (item) => console.log('Processing:', item),
|
|
30
|
+
* { started: true, wait: 1000 }
|
|
31
|
+
* );
|
|
32
|
+
*
|
|
33
|
+
* // Opt-in to track queue contents changes
|
|
34
|
+
* const queue = injectQueuer(
|
|
35
|
+
* (item) => console.log('Processing:', item),
|
|
36
|
+
* { started: true, wait: 1000 },
|
|
37
|
+
* (state) => ({ items: state.items, size: state.size })
|
|
38
|
+
* );
|
|
39
|
+
*
|
|
40
|
+
* // Add items
|
|
41
|
+
* queue.addItem('task1');
|
|
42
|
+
*
|
|
43
|
+
* // Access the selected state
|
|
44
|
+
* const { items, isRunning } = queue.state();
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
function injectQueuer(fn, options = {}, selector = () => ({})) {
|
|
48
|
+
const queuer = new _tanstack_pacer_queuer.Queuer(fn, {
|
|
49
|
+
...require_pacer_context.injectPacerOptions().queuer,
|
|
50
|
+
...options
|
|
51
|
+
});
|
|
52
|
+
const state = (0, _tanstack_angular_store.injectStore)(queuer.store, selector);
|
|
53
|
+
return {
|
|
54
|
+
...queuer,
|
|
55
|
+
state
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
exports.injectQueuer = injectQueuer;
|
|
61
|
+
//# sourceMappingURL=injectQueuer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injectQueuer.cjs","names":["Queuer","injectPacerOptions"],"sources":["../../src/queuer/injectQueuer.ts"],"sourcesContent":["import { injectStore } from '@tanstack/angular-store'\nimport { Queuer } from '@tanstack/pacer/queuer'\nimport { injectPacerOptions } from '../provider/pacer-context'\nimport type { Signal } from '@angular/core'\nimport type { Store } from '@tanstack/store'\nimport type { QueuerOptions, QueuerState } from '@tanstack/pacer/queuer'\n\nexport interface AngularQueuer<TValue, TSelected = {}> extends Omit<\n Queuer<TValue>,\n 'store'\n> {\n /**\n * Reactive state signal that will be updated when the queuer state changes\n *\n * Use this instead of `queuer.store.state`\n */\n readonly state: Signal<Readonly<TSelected>>\n /**\n * @deprecated Use `queuer.state` instead of `queuer.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<QueuerState<TValue>>>\n}\n\n/**\n * An Angular function that creates and manages a Queuer instance.\n *\n * This is a lower-level function that provides direct access to the Queuer's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * The Queuer processes items synchronously in order, with optional delays between processing each item.\n * The queuer includes an internal tick mechanism that can be started and stopped, making it useful as a scheduler.\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 * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const queue = injectQueuer(\n * (item) => console.log('Processing:', item),\n * { started: true, wait: 1000 }\n * );\n *\n * // Opt-in to track queue contents changes\n * const queue = injectQueuer(\n * (item) => console.log('Processing:', item),\n * { started: true, wait: 1000 },\n * (state) => ({ items: state.items, size: state.size })\n * );\n *\n * // Add items\n * queue.addItem('task1');\n *\n * // Access the selected state\n * const { items, isRunning } = queue.state();\n * ```\n */\nexport function injectQueuer<TValue, TSelected = {}>(\n fn: (item: TValue) => void,\n options: QueuerOptions<TValue> = {},\n selector: (state: QueuerState<TValue>) => TSelected = () => ({}) as TSelected,\n): AngularQueuer<TValue, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().queuer,\n ...options,\n } as QueuerOptions<TValue>\n\n const queuer = new Queuer<TValue>(fn, mergedOptions)\n const state = injectStore(queuer.store, selector)\n\n return {\n ...queuer,\n state,\n } as AngularQueuer<TValue, TSelected>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,SAAgB,aACd,IACA,UAAiC,EAAE,EACnC,kBAA6D,EAAE,GAC7B;CAMlC,MAAM,SAAS,IAAIA,8BAAe,IALZ;EACpB,GAAGC,0CAAoB,CAAC;EACxB,GAAG;EACJ,CAEmD;CACpD,MAAM,iDAAoB,OAAO,OAAO,SAAS;AAEjD,QAAO;EACL,GAAG;EACH;EACD"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Signal } from "@angular/core";
|
|
2
|
+
import { Store } from "@tanstack/store";
|
|
3
|
+
import { Queuer, QueuerOptions, QueuerState } from "@tanstack/pacer/queuer";
|
|
4
|
+
|
|
5
|
+
//#region src/queuer/injectQueuer.d.ts
|
|
6
|
+
interface AngularQueuer<TValue, TSelected = {}> extends Omit<Queuer<TValue>, 'store'> {
|
|
7
|
+
/**
|
|
8
|
+
* Reactive state signal that will be updated when the queuer state changes
|
|
9
|
+
*
|
|
10
|
+
* Use this instead of `queuer.store.state`
|
|
11
|
+
*/
|
|
12
|
+
readonly state: Signal<Readonly<TSelected>>;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Use `queuer.state` instead of `queuer.store.state` if you want to read reactive state.
|
|
15
|
+
* The state on the store object is not reactive in Angular signals.
|
|
16
|
+
*/
|
|
17
|
+
readonly store: Store<Readonly<QueuerState<TValue>>>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* An Angular function that creates and manages a Queuer instance.
|
|
21
|
+
*
|
|
22
|
+
* This is a lower-level function that provides direct access to the Queuer's functionality.
|
|
23
|
+
* This allows you to integrate it with any state management solution you prefer.
|
|
24
|
+
*
|
|
25
|
+
* The Queuer processes items synchronously in order, with optional delays between processing each item.
|
|
26
|
+
* The queuer includes an internal tick mechanism that can be started and stopped, making it useful as a scheduler.
|
|
27
|
+
*
|
|
28
|
+
* ## State Management and Selector
|
|
29
|
+
*
|
|
30
|
+
* The function uses TanStack Store for state management and wraps it with Angular signals.
|
|
31
|
+
* The `selector` parameter allows you to specify which state changes will trigger signal updates,
|
|
32
|
+
* optimizing performance by preventing unnecessary updates when irrelevant state changes occur.
|
|
33
|
+
*
|
|
34
|
+
* **By default, there will be no reactive state subscriptions** and you must opt-in to state
|
|
35
|
+
* tracking by providing a selector function. This prevents unnecessary updates and gives you
|
|
36
|
+
* full control over when your component tracks state changes.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* // Default behavior - no reactive state subscriptions
|
|
41
|
+
* const queue = injectQueuer(
|
|
42
|
+
* (item) => console.log('Processing:', item),
|
|
43
|
+
* { started: true, wait: 1000 }
|
|
44
|
+
* );
|
|
45
|
+
*
|
|
46
|
+
* // Opt-in to track queue contents changes
|
|
47
|
+
* const queue = injectQueuer(
|
|
48
|
+
* (item) => console.log('Processing:', item),
|
|
49
|
+
* { started: true, wait: 1000 },
|
|
50
|
+
* (state) => ({ items: state.items, size: state.size })
|
|
51
|
+
* );
|
|
52
|
+
*
|
|
53
|
+
* // Add items
|
|
54
|
+
* queue.addItem('task1');
|
|
55
|
+
*
|
|
56
|
+
* // Access the selected state
|
|
57
|
+
* const { items, isRunning } = queue.state();
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
declare function injectQueuer<TValue, TSelected = {}>(fn: (item: TValue) => void, options?: QueuerOptions<TValue>, selector?: (state: QueuerState<TValue>) => TSelected): AngularQueuer<TValue, TSelected>;
|
|
61
|
+
//#endregion
|
|
62
|
+
export { AngularQueuer, injectQueuer };
|
|
63
|
+
//# sourceMappingURL=injectQueuer.d.cts.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Signal } from "@angular/core";
|
|
2
|
+
import { Queuer, QueuerOptions, QueuerState } from "@tanstack/pacer/queuer";
|
|
3
|
+
import { Store } from "@tanstack/store";
|
|
4
|
+
|
|
5
|
+
//#region src/queuer/injectQueuer.d.ts
|
|
6
|
+
interface AngularQueuer<TValue, TSelected = {}> extends Omit<Queuer<TValue>, 'store'> {
|
|
7
|
+
/**
|
|
8
|
+
* Reactive state signal that will be updated when the queuer state changes
|
|
9
|
+
*
|
|
10
|
+
* Use this instead of `queuer.store.state`
|
|
11
|
+
*/
|
|
12
|
+
readonly state: Signal<Readonly<TSelected>>;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Use `queuer.state` instead of `queuer.store.state` if you want to read reactive state.
|
|
15
|
+
* The state on the store object is not reactive in Angular signals.
|
|
16
|
+
*/
|
|
17
|
+
readonly store: Store<Readonly<QueuerState<TValue>>>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* An Angular function that creates and manages a Queuer instance.
|
|
21
|
+
*
|
|
22
|
+
* This is a lower-level function that provides direct access to the Queuer's functionality.
|
|
23
|
+
* This allows you to integrate it with any state management solution you prefer.
|
|
24
|
+
*
|
|
25
|
+
* The Queuer processes items synchronously in order, with optional delays between processing each item.
|
|
26
|
+
* The queuer includes an internal tick mechanism that can be started and stopped, making it useful as a scheduler.
|
|
27
|
+
*
|
|
28
|
+
* ## State Management and Selector
|
|
29
|
+
*
|
|
30
|
+
* The function uses TanStack Store for state management and wraps it with Angular signals.
|
|
31
|
+
* The `selector` parameter allows you to specify which state changes will trigger signal updates,
|
|
32
|
+
* optimizing performance by preventing unnecessary updates when irrelevant state changes occur.
|
|
33
|
+
*
|
|
34
|
+
* **By default, there will be no reactive state subscriptions** and you must opt-in to state
|
|
35
|
+
* tracking by providing a selector function. This prevents unnecessary updates and gives you
|
|
36
|
+
* full control over when your component tracks state changes.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* // Default behavior - no reactive state subscriptions
|
|
41
|
+
* const queue = injectQueuer(
|
|
42
|
+
* (item) => console.log('Processing:', item),
|
|
43
|
+
* { started: true, wait: 1000 }
|
|
44
|
+
* );
|
|
45
|
+
*
|
|
46
|
+
* // Opt-in to track queue contents changes
|
|
47
|
+
* const queue = injectQueuer(
|
|
48
|
+
* (item) => console.log('Processing:', item),
|
|
49
|
+
* { started: true, wait: 1000 },
|
|
50
|
+
* (state) => ({ items: state.items, size: state.size })
|
|
51
|
+
* );
|
|
52
|
+
*
|
|
53
|
+
* // Add items
|
|
54
|
+
* queue.addItem('task1');
|
|
55
|
+
*
|
|
56
|
+
* // Access the selected state
|
|
57
|
+
* const { items, isRunning } = queue.state();
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
declare function injectQueuer<TValue, TSelected = {}>(fn: (item: TValue) => void, options?: QueuerOptions<TValue>, selector?: (state: QueuerState<TValue>) => TSelected): AngularQueuer<TValue, TSelected>;
|
|
61
|
+
//#endregion
|
|
62
|
+
export { AngularQueuer, injectQueuer };
|
|
63
|
+
//# sourceMappingURL=injectQueuer.d.ts.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { injectPacerOptions } from "../provider/pacer-context.js";
|
|
2
|
+
import { injectStore } from "@tanstack/angular-store";
|
|
3
|
+
import { Queuer } from "@tanstack/pacer/queuer";
|
|
4
|
+
|
|
5
|
+
//#region src/queuer/injectQueuer.ts
|
|
6
|
+
/**
|
|
7
|
+
* An Angular function that creates and manages a Queuer instance.
|
|
8
|
+
*
|
|
9
|
+
* This is a lower-level function that provides direct access to the Queuer's functionality.
|
|
10
|
+
* This allows you to integrate it with any state management solution you prefer.
|
|
11
|
+
*
|
|
12
|
+
* The Queuer processes items synchronously in order, with optional delays between processing each item.
|
|
13
|
+
* The queuer includes an internal tick mechanism that can be started and stopped, making it useful as a scheduler.
|
|
14
|
+
*
|
|
15
|
+
* ## State Management and Selector
|
|
16
|
+
*
|
|
17
|
+
* The function uses TanStack Store for state management and wraps it with Angular signals.
|
|
18
|
+
* The `selector` parameter allows you to specify which state changes will trigger signal updates,
|
|
19
|
+
* optimizing performance by preventing unnecessary updates when irrelevant state changes occur.
|
|
20
|
+
*
|
|
21
|
+
* **By default, there will be no reactive state subscriptions** and you must opt-in to state
|
|
22
|
+
* tracking by providing a selector function. This prevents unnecessary updates and gives you
|
|
23
|
+
* full control over when your component tracks state changes.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* // Default behavior - no reactive state subscriptions
|
|
28
|
+
* const queue = injectQueuer(
|
|
29
|
+
* (item) => console.log('Processing:', item),
|
|
30
|
+
* { started: true, wait: 1000 }
|
|
31
|
+
* );
|
|
32
|
+
*
|
|
33
|
+
* // Opt-in to track queue contents changes
|
|
34
|
+
* const queue = injectQueuer(
|
|
35
|
+
* (item) => console.log('Processing:', item),
|
|
36
|
+
* { started: true, wait: 1000 },
|
|
37
|
+
* (state) => ({ items: state.items, size: state.size })
|
|
38
|
+
* );
|
|
39
|
+
*
|
|
40
|
+
* // Add items
|
|
41
|
+
* queue.addItem('task1');
|
|
42
|
+
*
|
|
43
|
+
* // Access the selected state
|
|
44
|
+
* const { items, isRunning } = queue.state();
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
function injectQueuer(fn, options = {}, selector = () => ({})) {
|
|
48
|
+
const queuer = new Queuer(fn, {
|
|
49
|
+
...injectPacerOptions().queuer,
|
|
50
|
+
...options
|
|
51
|
+
});
|
|
52
|
+
const state = injectStore(queuer.store, selector);
|
|
53
|
+
return {
|
|
54
|
+
...queuer,
|
|
55
|
+
state
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
export { injectQueuer };
|
|
61
|
+
//# sourceMappingURL=injectQueuer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injectQueuer.js","names":[],"sources":["../../src/queuer/injectQueuer.ts"],"sourcesContent":["import { injectStore } from '@tanstack/angular-store'\nimport { Queuer } from '@tanstack/pacer/queuer'\nimport { injectPacerOptions } from '../provider/pacer-context'\nimport type { Signal } from '@angular/core'\nimport type { Store } from '@tanstack/store'\nimport type { QueuerOptions, QueuerState } from '@tanstack/pacer/queuer'\n\nexport interface AngularQueuer<TValue, TSelected = {}> extends Omit<\n Queuer<TValue>,\n 'store'\n> {\n /**\n * Reactive state signal that will be updated when the queuer state changes\n *\n * Use this instead of `queuer.store.state`\n */\n readonly state: Signal<Readonly<TSelected>>\n /**\n * @deprecated Use `queuer.state` instead of `queuer.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<QueuerState<TValue>>>\n}\n\n/**\n * An Angular function that creates and manages a Queuer instance.\n *\n * This is a lower-level function that provides direct access to the Queuer's functionality.\n * This allows you to integrate it with any state management solution you prefer.\n *\n * The Queuer processes items synchronously in order, with optional delays between processing each item.\n * The queuer includes an internal tick mechanism that can be started and stopped, making it useful as a scheduler.\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 * @example\n * ```ts\n * // Default behavior - no reactive state subscriptions\n * const queue = injectQueuer(\n * (item) => console.log('Processing:', item),\n * { started: true, wait: 1000 }\n * );\n *\n * // Opt-in to track queue contents changes\n * const queue = injectQueuer(\n * (item) => console.log('Processing:', item),\n * { started: true, wait: 1000 },\n * (state) => ({ items: state.items, size: state.size })\n * );\n *\n * // Add items\n * queue.addItem('task1');\n *\n * // Access the selected state\n * const { items, isRunning } = queue.state();\n * ```\n */\nexport function injectQueuer<TValue, TSelected = {}>(\n fn: (item: TValue) => void,\n options: QueuerOptions<TValue> = {},\n selector: (state: QueuerState<TValue>) => TSelected = () => ({}) as TSelected,\n): AngularQueuer<TValue, TSelected> {\n const mergedOptions = {\n ...injectPacerOptions().queuer,\n ...options,\n } as QueuerOptions<TValue>\n\n const queuer = new Queuer<TValue>(fn, mergedOptions)\n const state = injectStore(queuer.store, selector)\n\n return {\n ...queuer,\n state,\n } as AngularQueuer<TValue, TSelected>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,SAAgB,aACd,IACA,UAAiC,EAAE,EACnC,kBAA6D,EAAE,GAC7B;CAMlC,MAAM,SAAS,IAAI,OAAe,IALZ;EACpB,GAAG,oBAAoB,CAAC;EACxB,GAAG;EACJ,CAEmD;CACpD,MAAM,QAAQ,YAAY,OAAO,OAAO,SAAS;AAEjD,QAAO;EACL,GAAG;EACH;EACD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_injectRateLimiter = require('./injectRateLimiter.cjs');
|
|
3
|
+
const require_injectRateLimitedCallback = require('./injectRateLimitedCallback.cjs');
|
|
4
|
+
const require_injectRateLimitedSignal = require('./injectRateLimitedSignal.cjs');
|
|
5
|
+
const require_injectRateLimitedValue = require('./injectRateLimitedValue.cjs');
|
|
6
|
+
|
|
7
|
+
exports.injectRateLimitedCallback = require_injectRateLimitedCallback.injectRateLimitedCallback;
|
|
8
|
+
exports.injectRateLimitedSignal = require_injectRateLimitedSignal.injectRateLimitedSignal;
|
|
9
|
+
exports.injectRateLimitedValue = require_injectRateLimitedValue.injectRateLimitedValue;
|
|
10
|
+
exports.injectRateLimiter = require_injectRateLimiter.injectRateLimiter;
|
|
11
|
+
var _tanstack_pacer_rate_limiter = require("@tanstack/pacer/rate-limiter");
|
|
12
|
+
Object.keys(_tanstack_pacer_rate_limiter).forEach(function (k) {
|
|
13
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return _tanstack_pacer_rate_limiter[k]; }
|
|
16
|
+
});
|
|
17
|
+
});
|