function asyncQueue<TValue>(fn, initialOptions): (item, position, runOnItemsChange) => boolean
function asyncQueue<TValue>(fn, initialOptions): (item, position, runOnItemsChange) => boolean
Defined in: async-queuer.ts:781
Creates a new AsyncQueuer instance and returns a bound addItem function for adding tasks. The queuer is started automatically and ready to process items.
Error Handling:
State Management:
Example usage:
const enqueue = asyncQueue<string>(async (item) => {
return item.toUpperCase();
}, {...options});
enqueue('hello');
const enqueue = asyncQueue<string>(async (item) => {
return item.toUpperCase();
}, {...options});
enqueue('hello');
• TValue
(value) => Promise<any>
AsyncQueuerOptions<TValue>
Function
Adds an item to the queue. If the queue is full, the item is rejected and onReject is called. Items can be inserted based on priority or at the front/back depending on configuration.
TValue
QueuePosition = ...
boolean = true
boolean
queuer.addItem({ value: 'task', priority: 10 });
queuer.addItem('task2', 'front');
queuer.addItem({ value: 'task', priority: 10 });
queuer.addItem('task2', 'front');
Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.
Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.