File: asyncQueue.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
React
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
TanStack Query Examples
Framework
React
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
TanStack Query Examples
On this page
Copy Markdown
Function: asyncQueue()
======================
ts
function asyncQueue<TValue>(fn, initialOptions): (item, position, runOnItemsChange) => boolean;
function asyncQueue<TValue>(fn, initialOptions): (item, position, runOnItemsChange) => boolean;
Defined in: async-queuer.ts:914
Creates a new AsyncQueuer instance and returns a bound addItem function for adding tasks. The queuer is started automatically and ready to process items.
Async vs Sync Versions: The async version provides advanced features over the sync queue function:
The sync queue function is lighter weight and simpler when you don't need async features, return values, or execution control.
What is Queuing? Queuing is a technique for managing and processing items sequentially or with controlled concurrency. Tasks are processed up to the configured concurrency limit. When a task completes, the next pending task is processed if the concurrency limit allows.
Configuration Options:
Error Handling:
State Management:
Type Parameters
---------------
### TValue
TValue
(value) => Promise<any>
AsyncQueuerOptions <TValue>
ts
(
item,
position,
runOnItemsChange): boolean;
(
item,
position,
runOnItemsChange): boolean;
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
ts
queuer.addItem({ value: 'task', priority: 10 });
queuer.addItem('task2', 'front');
queuer.addItem({ value: 'task', priority: 10 });
queuer.addItem('task2', 'front');
ts
const enqueue = asyncQueue<string>(async (item) => {
return item.toUpperCase();
}, {
concurrency: 2,
wait: 100,
onSuccess: (result) => console.log('Processed:', result)
});
enqueue('hello');
const enqueue = asyncQueue<string>(async (item) => {
return item.toUpperCase();
}, {
concurrency: 2,
wait: 100,
onSuccess: (result) => console.log('Processed:', result)
});
enqueue('hello');
