function createAsyncQueuer<TValue>(fn, initialOptions): SolidAsyncQueuer<TValue>
function createAsyncQueuer<TValue>(fn, initialOptions): SolidAsyncQueuer<TValue>
Defined in: async-queuer/createAsyncQueuer.ts:130
Creates a Solid-compatible AsyncQueuer instance for managing an asynchronous queue of items, exposing Solid signals for all stateful properties.
Features:
Tasks are processed concurrently up to the configured concurrency limit. When a task completes, the next pending task is processed if the concurrency limit allows.
Error Handling:
Example usage:
// Basic async queuer for API requests
const asyncQueuer = createAsyncQueuer(async (item) => {
// process item
return await fetchData(item);
}, {
initialItems: [],
concurrency: 2,
maxSize: 100,
started: false,
onSuccess: (result) => {
console.log('Item processed:', result);
},
onError: (error) => {
console.error('Processing failed:', error);
}
});
// Add items to queue
asyncQueuer.addItem(newItem);
// Start processing
asyncQueuer.start();
// Use Solid signals in your UI
const pending = asyncQueuer.pendingItems();
// Basic async queuer for API requests
const asyncQueuer = createAsyncQueuer(async (item) => {
// process item
return await fetchData(item);
}, {
initialItems: [],
concurrency: 2,
maxSize: 100,
started: false,
onSuccess: (result) => {
console.log('Item processed:', result);
},
onError: (error) => {
console.error('Processing failed:', error);
}
});
// Add items to queue
asyncQueuer.addItem(newItem);
// Start processing
asyncQueuer.start();
// Use Solid signals in your UI
const pending = asyncQueuer.pendingItems();
• TValue
(value) => Promise<any>
AsyncQueuerOptions<TValue> = {}
SolidAsyncQueuer<TValue>
Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.