Debouncer API Reference
- DebouncerOptions
- DebouncerState
- AsyncDebouncerOptions
- AsyncDebouncerState
- debounce
- asyncDebounce
- Debouncer
- AsyncDebouncer
- ReactDebouncerOptions
- ReactAsyncDebouncerOptions
- ReactDebouncer
- ReactAsyncDebouncer
- useDebouncer
- useDebouncedCallback
- useDebouncedState
- useDebouncedValue
- useAsyncDebouncer
- useAsyncDebouncedCallback
Throttler API Reference
- ThrottlerOptions
- ThrottlerState
- AsyncThrottlerOptions
- AsyncThrottlerState
- throttle
- asyncThrottle
- Throttler
- AsyncThrottler
- ReactThrottlerOptions
- ReactAsyncThrottlerOptions
- ReactThrottler
- ReactAsyncThrottler
- useThrottler
- useThrottledCallback
- useThrottledState
- useThrottledValue
- useAsyncThrottler
- useAsyncThrottledCallback
Rate Limiter API Reference
Queue API Reference
queue
function queue<TValue>(fn, initialOptions): (item, position, runOnItemsChange) => boolean;Defined in: queuer.ts:745
Creates a queue that processes items immediately upon addition. Items are processed sequentially in FIFO order by default.
This synchronous version is lighter weight and often all you need - upgrade to asyncQueue when you need promises, retry support, abort capabilities, concurrent execution, or advanced error handling.
State Management:
- Uses TanStack Store for reactive state management
- Use initialState to provide initial state values when creating the queuer
- Use onExecute callback to react to item execution and implement custom logic
- Use onItemsChange callback to react to items being added or removed from the queue
- Use onExpire callback to react to items expiring and implement custom logic
- Use onReject callback to react to items being rejected when the queue is full
- The state includes execution count, expiration count, rejection count, and isRunning status
- State can be accessed via the underlying Queuer instance's store.state property
- When using framework adapters (React/Solid), state is accessed from the hook's state property
Example usage:
// Basic sequential processing
const processItems = queue<number>((n) => console.log(n), {
wait: 1000,
onItemsChange: (queuer) => console.log(queuer.peekAllItems())
});
processItems(1); // Logs: 1
processItems(2); // Logs: 2 after 1 completes
// Priority queue
const processPriority = queue<number>((n) => console.log(n), {
getPriority: n => n // Higher numbers processed first
});
processPriority(1);
processPriority(3); // Processed before 1Type Parameters#
TValue#
TValue
Parameters#
fn#
(item) => void
initialOptions#
QueuerOptions<TValue>
Returns#
(
item,
position?,
runOnItemsChange?): boolean;Adds an item to the queue. If the queue is full, the item is rejected and onReject is called. undefined cannot be queued (it is the internal "no item" sentinel) and is always rejected. Items can be inserted based on priority or at the front/back depending on configuration.
Returns true if the item was added, false if the queue is full.
Example usage:
queuer.addItem('task');
queuer.addItem('task2', 'front');Parameters#
item#
TValue
position?#
QueuePosition = ...
runOnItemsChange?#
boolean = true
Returns#
boolean