function asyncQueue<TValue>(fn, initialOptions): (item, position, runOnItemsChange) => void
function asyncQueue<TValue>(fn, initialOptions): (item, position, runOnItemsChange) => void
Defined in: async-queuer.ts:612
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:
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 & object
QueuePosition = ...
boolean = true
void
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.