Skip to main content
You are viewing Pre-Alpha documentation.
Vuetify0 Logo

createQueue

A queue composable for managing time-based collections with automatic timeout-based removal, pause/resume functionality, and FIFO (First In, First Out) ordering.

Usage

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

Architecture

useQueue extends useRegistry with FIFO ordering and timeout management:

Diagram

Click outside or press Escape to close

API Reference

The following API details are for the useQueue composable.

Functions

createQueue

(_options?: QueueOptions) => E

Creates a new queue instance

createQueueContext

(_options?: QueueContextOptions) => ContextTrinity<E>

Creates a new queue context.

useQueue

(namespace?: string) => E

Returns the current queue instance.

Options

events

boolean

Enable event emission for registry operations

Default: false

timeout

number

Default timeout in milliseconds for tickets without explicit timeout

Default: 3000

Properties

collection

ReadonlyMap<ID, Z>

The collection of tickets in the registry

size

number

The number of tickets in the registry

Methods

clear

() => void

Clear the entire registry

has

(id: ID) => boolean

Check if a ticket exists by ID

keys

() => ID[]

Get all registered IDs

browse

(value: unknown) => ID[] | undefined

Browse for an ID(s) by value

lookup

(index: number) => ID | undefined

lookup a ticket by index number

get

(id: ID) => Z | undefined

Get a ticket by ID

upsert

(id: ID, ticket?: Partial<Z>) => Z

Update or insert a ticket by ID

values

() => Z[]

Get all values of registered tickets

entries

() => [ID, Z][]

Get all entries of registered tickets

register

(ticket?: Partial<Z>) => Z

Register a new ticket

unregister

(id: ID) => void

Unregister an ticket by ID

reindex

() => void

Reset the index directory and update all tickets

seek

(direction?: "first" | "last", from?: number, predicate?: (ticket) => boolean) => Z | undefined

Seek for a ticket based on direction and optional predicate

on

(event: string, cb: RegistryEventCallback) => void

Listen for registry events

off

(event: string, cb: RegistryEventCallback) => void

Stop listening for registry events

emit

(event: string, data: unknown) => void

Emit an event with data

dispose

() => void

Clears the registry and removes all listeners

onboard

(registrations: Partial<Z>[]) => Z[]

Onboard multiple tickets at once

offboard

(ids: ID[]) => void

Offboard multiple tickets at once

batch

<R>(fn: () => R) => R

Execute operations in a batch, deferring cache invalidation and event emission until complete

pause

() => Z | undefined

Pause the timeout of the first ticket in the queue

resume

() => Z | undefined

Resume the timeout of the first paused ticket in the queue


© 2016-2026 Vuetify, LLC
Ctrl+/