A queue composable for managing time-based collections with automatic timeout-based removal, pause/resume functionality, and FIFO (First In, First Out) ordering.
The useQueue composable provides a powerful interface for managing time-based queues. Built on top of useRegistry, it automatically manages timeouts for items, ensuring only the first item in the queue is active at any time. When an item expires or is removed, the next item in the queue automatically becomes active.
ts import { createQueue } from '@vuetify/v0'
const queue = createQueue ()
const item1 = queue. register ({ value: 'First' })
const item2 = queue. register ({ value: 'Second' })
const item3 = queue. register ({ value: 'Third' })
console. log (item1.isPaused) // false (first item is active)
console. log (item2.isPaused) // true (waiting in queue)
console. log (queue.size) // 3 useQueue extends useRegistry with FIFO ordering and timeout management:
Diagram Click outside or press Escape to close
View standalone → The following API details are for the
useQueue composable.
(_options?: QueueOptions) => ECreates a new queue instance
Show code example
(_options?: QueueContextOptions) => ContextTrinity<E>Creates a new queue context.
Show code example
(namespace?: string) => EReturns the current queue instance.
Show code example
booleanEnable event emission for registry operations
Default: false
numberDefault timeout in milliseconds for tickets without explicit timeout
Default: 3000
ReadonlyMap<ID, Z>The collection of tickets in the registry
numberThe number of tickets in the registry
Show code example
() => voidClear the entire registry
Show code example
(id: ID) => booleanCheck if a ticket exists by ID
Show code example
() => ID[]Get all registered IDs
Show code example
(value: unknown) => ID[] | undefinedBrowse for an ID(s) by value
Show code example
(index: number) => ID | undefinedlookup a ticket by index number
Show code example
(id: ID) => Z | undefinedGet a ticket by ID
Show code example
(id: ID, ticket?: Partial<Z>) => ZUpdate or insert a ticket by ID
Show code example
() => Z[]Get all values of registered tickets
Show code example
() => [ID, Z][]Get all entries of registered tickets
Show code example
(ticket?: Partial<Z>) => ZRegister a new ticket
Show code example
(id: ID) => voidUnregister an ticket by ID
Show code example
() => voidReset the index directory and update all tickets
Show code example
(direction?: "first" | "last", from?: number, predicate?: (ticket) => boolean) => Z | undefinedSeek for a ticket based on direction and optional predicate
Show code example
(event: string, cb: RegistryEventCallback) => voidListen for registry events
Show code example
(event: string, cb: RegistryEventCallback) => voidStop listening for registry events
Show code example
(event: string, data: unknown) => voidEmit an event with data
Show code example
() => voidClears the registry and removes all listeners
Show code example
(registrations: Partial<Z>[]) => Z[]Onboard multiple tickets at once
Show code example
(ids: ID[]) => voidOffboard multiple tickets at once
Show code example
<R>(fn: () => R) => RExecute operations in a batch, deferring cache invalidation and event emission until complete
Show code example
() => Z | undefinedPause the timeout of the first ticket in the queue
Show code example
() => Z | undefinedResume the timeout of the first paused ticket in the queue
Show code example