function injectAsyncQueuedSignal<TValue, TSelected>(
fn,
options,
selector): AsyncQueuedSignal<TValue, TSelected>;
Defined in: async-queuer/injectAsyncQueuedSignal.ts:60
An Angular function that creates an async queuer with managed state, combining Angular's signals with async queuing functionality. This function provides both the current queue state and queue control methods.
The queue state is automatically updated whenever items are added, removed, or processed in the queue. All queue operations are reflected in the state array returned by the function.
The function returns a callable object:
TValue
TSelected extends Pick<AsyncQueuerState<TValue>, "items"> = Pick<AsyncQueuerState<TValue>, "items">
(value) => Promise<any>
AsyncQueuerOptions<TValue> = {}
(state) => TSelected
AsyncQueuedSignal<TValue, TSelected>
// Default behavior - track items
const queued = injectAsyncQueuedSignal(
async (item) => {
const response = await fetch('/api/process', {
method: 'POST',
body: JSON.stringify(item)
});
return response.json();
},
{ concurrency: 2, wait: 1000 }
);
// Add items
queued.addItem(data1);
// Access items
console.log(queued()); // [data1, ...]
// Control the queue
queued.queuer.start();
queued.queuer.stop();