File: createAsyncQueuer.md | Updated: 11/15/2025
Search...
+ K
Auto
Docs Examples GitHub Contributors
Docs Examples GitHub Contributors
Docs Examples GitHub Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Maintainers Partners Support Learn StatsBETA Discord Merch Blog GitHub Ethos Brand Guide
Documentation
Framework
Solid
Version
Latest
Search...
+ K
Menu
Getting Started
Guides
API Reference
Debouncer API Reference
Throttler API Reference
Rate Limiter API Reference
Queue API Reference
Batcher API Reference
Debouncer Examples
Throttler Examples
Rate Limiter Examples
Queue Examples
Batcher Examples
Framework
Solid
Version
Latest
Menu
Getting Started
Guides
API Reference
Debouncer API Reference
Throttler API Reference
Rate Limiter API Reference
Queue API Reference
Batcher API Reference
Debouncer Examples
Throttler Examples
Rate Limiter Examples
Queue Examples
Batcher Examples
On this page
Copy Markdown
Function: createAsyncQueuer()
=============================
ts
function createAsyncQueuer<TValue, TSelected>(
fn,
initialOptions,
selector): SolidAsyncQueuer<TValue, TSelected>;
function createAsyncQueuer<TValue, TSelected>(
fn,
initialOptions,
selector): SolidAsyncQueuer<TValue, TSelected>;
Defined in: async-queuer/createAsyncQueuer.ts:120
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:
State Management and Selector
-----------------------------
The hook uses TanStack Store for reactive state management. The selector parameter allows you to specify which state changes will trigger a re-render, optimizing performance by preventing unnecessary re-renders when irrelevant state changes occur.
By default, there will be no reactive state subscriptions and you must opt-in to state tracking by providing a selector function. This prevents unnecessary re-renders and gives you full control over when your component updates. Only when you provide a selector will the component re-render when the selected state values change.
Available state properties:
Example usage:
tsx
// Default behavior - no reactive state subscriptions
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);
}
});
// Opt-in to re-render when queue state changes (optimized for UI updates)
const asyncQueuer = createAsyncQueuer(
async (item) => await fetchData(item),
{ concurrency: 2, started: true },
(state) => ({
pendingItems: state.pendingItems,
activeItems: state.activeItems,
isRunning: state.isRunning
})
);
// Opt-in to re-render when processing metrics change (optimized for tracking progress)
const asyncQueuer = createAsyncQueuer(
async (item) => await fetchData(item),
{ concurrency: 2, started: true },
(state) => ({
successCount: state.successCount,
errorCount: state.errorCount,
settleCount: state.settleCount
})
);
// Add items to queue
asyncQueuer.addItem(newItem);
// Start processing
asyncQueuer.start();
// Access the selected state (will be empty object {} unless selector provided)
const { pendingItems, activeItems } = asyncQueuer.state();
// Default behavior - no reactive state subscriptions
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);
}
});
// Opt-in to re-render when queue state changes (optimized for UI updates)
const asyncQueuer = createAsyncQueuer(
async (item) => await fetchData(item),
{ concurrency: 2, started: true },
(state) => ({
pendingItems: state.pendingItems,
activeItems: state.activeItems,
isRunning: state.isRunning
})
);
// Opt-in to re-render when processing metrics change (optimized for tracking progress)
const asyncQueuer = createAsyncQueuer(
async (item) => await fetchData(item),
{ concurrency: 2, started: true },
(state) => ({
successCount: state.successCount,
errorCount: state.errorCount,
settleCount: state.settleCount
})
);
// Add items to queue
asyncQueuer.addItem(newItem);
// Start processing
asyncQueuer.start();
// Access the selected state (will be empty object {} unless selector provided)
const { pendingItems, activeItems } = asyncQueuer.state();
Type Parameters
---------------
### TValue
TValue
TSelected = { }
(value) => Promise<any>
AsyncQueuerOptions<TValue> = {}
(state) => TSelected
SolidAsyncQueuer <TValue, TSelected>
