Skip to main content
Vuetify0 is now in alpha!
Vuetify0 Logo
Theme
Mode
Palettes
Accessibility
Vuetify One
Sign in to Vuetify One

Access premium tools across the Vuetify ecosystem — Bin, Play, Studio, and more.

Not a subscriber? See what's included

createQueue

FIFO queue for time-based collections with automatic timeout removal and pause/resume support.


AdvancedApr 5, 2026

Usage

ts
import { createQueue } from '@vuetify/v0'
import type { QueueTicket } from '@vuetify/v0'

interface Task extends QueueTicket {
  name: string
  priority: number
}

const queue = createQueue<Task>({ timeout: 5000 })

const task = queue.register({ name: 'Build assets', priority: 1 })

console.log(task.isPaused.value) // false (first item is active)
console.log(queue.size) // 1

// Pause all timers
queue.pause()

// Resume timers
queue.resume()

Context / DI

Use createQueueContext to share a queue instance across a component tree:

ts
import { createQueueContext } from '@vuetify/v0'

export const [useToasts, provideToasts, toasts] =
  createQueueContext({ namespace: 'my:toasts', timeout: 5000 })

// In parent component
provideToasts()

// In child component
const queue = useToasts()
queue.register({ id: crypto.randomUUID(), value: 'Saved!' })

Architecture

createQueue extends createRegistry with FIFO ordering and timeout management:

Queue Hierarchy

Use controls to zoom and pan. Click outside or press Escape to close.

Queue Hierarchy

Timeout Behavior

The timeout option controls how long a ticket stays in the queue before auto-removal:

ValueBehavior
undefinedUses the global default from queue options (default: 3000ms)
numberAuto-removed after that many milliseconds
-1Persistent — never auto-removed, must call ticket.dismiss() manually

Only the first ticket runs its timer at any time. All others wait with isPaused: true until they reach the front.

ts
const queue = createQueue({ timeout: 5000 }) // global default

queue.register({ value: 'Auto (5s)' })             // uses 5000ms
queue.register({ value: 'Custom (10s)', timeout: 10000 })
queue.register({ value: 'Sticky', timeout: -1 })   // must be dismissed
Tip

Hover-to-pause pattern Call queue.pause() on mouseenter and queue.resume() on mouseleave to pause the active toast while the user reads it.

Reactivity

createQueue extends createRegistry with minimal reactivity for performance. Timeout state is managed internally.

Property/MethodNotes
register(ticket?)Add to queue; starts timer if first, otherwise paused
unregister(id?)Remove by ID, or first ticket if omitted. Returns the removed ticket
pause()Pause the first ticket’s timer. Returns the paused ticket or undefined
resume()Resume the first paused ticket’s timer. Resets to full duration
ticket isPausedtrue while waiting in queue or manually paused
ticket dismiss()Shorthand for queue.unregister(ticket.id)
Tip

Need reactive queue items? Wrap with useProxyRegistry(queue) for full template reactivity.

Examples

Upload Queue

This example demonstrates sequential processing with createQueue. Unlike notifications that display simultaneously, the queue processes one item at a time—the first item uploads while others wait their turn.

Provider/Consumer Data Flow

Use controls to zoom and pan. Click outside or press Escape to close.

Provider/Consumer Data Flow

File breakdown:

FileRole
context.tsDefines UploadInput/Upload types and the context with first, add, cancel
UploadProvider.vueCreates the queue, exposes first computed, watches it to start processing
UploadConsumer.vueDisplays first item with progress bar, pending items in FIFO order
uploads.vueEntry point that composes Provider around Consumer

Key patterns:

  • Expose first as a computed from proxy.values[0]

  • Watch first to react when a new item becomes active

  • useProxyRegistry for reactive access to queue items

  • Items auto-advance when the first one completes

Click “Add File” multiple times to see queuing behavior. Only one file uploads at a time.

No files in queue

API Reference

The following API details are for the createQueue composable.

Functions

createQueue

(_options?: QueueOptions) => QueueContext<QueueTicketInput<unknown>, QueueTicket<QueueTicketInput<unknown>>>

Creates a new queue instance

createQueueContext

(_options?: QueueContextOptions) => ContextTrinity<QueueContext<QueueTicketInput<unknown>, QueueTicket<QueueTicketInput<unknown>>>>

Creates a new queue context.

useQueue

(namespace?: string) => QueueContext<QueueTicketInput<unknown>, QueueTicket<QueueTicketInput<unknown>>>

Returns the current queue instance.

Options

events

boolean | undefined

Enable event emission for registry operations

Default: false

reactive

boolean | undefined

Enable reactive behavior for registry operations

Default: false

timeout

number | undefined

Default timeout in milliseconds for tickets without explicit timeout

Default: 3000

Properties

collection

ReadonlyMap<ID, E>

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

() => readonly ID[]

Get all registered IDs

browse

(value: E["value"]) => ID[] | undefined

Browse for an ID(s) by value

lookup

(index: number) => ID | undefined

lookup a ticket by index number

get

(id: ID) => E | undefined

Get a ticket by ID

upsert

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

Update or insert a ticket by ID

values

() => readonly E[]

Get all values of registered tickets

entries

() => readonly [ID, E][]

Get all entries of registered tickets

reindex

() => void

Reset the index directory and update all tickets

move

(id: ID, toIndex: number) => E | undefined

Seek for a ticket based on direction and optional predicate

seek

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

on

<K extends Extensible<RegistryEventName>>(event: K, cb: EventHandler<E, K>) => void

Listen for registry events

off

<K extends Extensible<RegistryEventName>>(event: K, cb: EventHandler<E, K>) => void

Stop listening for registry events

emit

<K extends Extensible<RegistryEventName>>(event: K, data: EventPayload<E, K>) => void

Emit an event with data

dispose

() => void

Clears the registry and removes all listeners

onboard

(registrations: Partial<Z & RegistryTicket>[]) => E[]

Onboard multiple tickets at once

batch

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

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

register

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

Register a new ticket in the queue (accepts input type, returns output type)

unregister

(id?: ID) => E | undefined

Unregister a ticket from the queue

pause

() => E | undefined

Pause the timeout of the first ticket in the queue

resume

() => E | undefined

Resume the timeout of the first paused ticket in the queue

offboard

(ids: ID[]) => void

Batch unregister tickets from the queue

Was this page helpful?

© 2016-1970 Vuetify, LLC
Ctrl+/