createRegistry
Foundation for ordered, keyed collections. Items are registered with IDs and indexes, and can be looked up by ID, index, or value.
Usage
The createRegistry composable provides a powerful interface for managing collections of items in a registration-based system. It allows you to register, unregister, and look up items efficiently, while maintaining an index for quick access.
Pass both generics: the input shape you hand to register() first, the resolved ticket you read back second. With only the input type, ticket.value widens to string | undefined; passing the output type alone is reserved for wrappers that fix their own ticket shape, such as createForm and createQueue.
Context / DI
Use createRegistryContext to share a registry across a component tree. Pass a fresh createRegistry() to the provider so each app instance owns its registry, created with the same options: what you pass to createRegistryContext only configures the module-scope default that a bare provideItems() would provide.
import { createRegistry, createRegistryContext } from '@vuetify/v0'
export const [useItems, provideItems, items] =
createRegistryContext({ namespace: 'my:items', events: true })
// In the root component — one registry per app instance, with the same options
provideItems(createRegistry({ events: true }))
// In child components
const registry = useItems()
registry.register({ id: 'item-1', value: 'First' })Architecture
createRegistry is the foundation for specialized registration systems:
Each branch extends the base ticket pattern with domain-specific capabilities. See individual composable docs for their extension hierarchies.
Reactivity
createRegistry uses minimal reactivity by default for performance. Collection methods are not reactive unless you opt in.
| Method | Notes |
|---|---|
register(ticket) | Append a ticket to the registry; a supplied index is ignored — use move() to position |
unregister(id) | Remove a ticket by ID |
upsert(id, partial) | Register or update a ticket |
move(id, index) | Move a ticket to a new index position; reindexes only the affected [from..to] span |
reorder(ids) | Reorder the registry to match a canonical permutation in one O(n) pass |
onboard(tickets) | Batch-register an array of tickets |
offboard(ids) | Batch-unregister an array of IDs |
batch(fn) | Run multiple mutations with events and the reactive notification deferred to the end |
get(id) | Retrieve a ticket by ID |
has(id) | Check whether a ticket ID is registered |
browse(value) | Reverse-lookup — find ticket ID(s) by value |
lookup(index) | Find ticket ID by zero-based index |
seek(direction, from?, predicate?) | Find 'first' or 'last' ticket, optionally starting from an index and/or filtered by predicate |
keys() | All registered IDs as a readonly array |
values() | All registered tickets as a readonly array |
entries() | All [id, ticket] pairs as a readonly array |
clear() | Remove all tickets |
dispose() | Remove all tickets and clear event listeners |
Need reactive collections? Pass { reactive: true } to make keys(), values(), entries(), size, and per-ticket field reads reactive in templates and computeds. Upserts on existing tickets propagate through the shallowReactive wrapping. For event-driven snapshots — or when you want deep: true tracking or need reactivity without wrapping the tickets themselves — use useProxyRegistry with { events: true }.
Examples
Event log
+ Registered "Set up CI pipeline"
+ Registered "Write unit tests"
+ Registered "Update README"
+ Registered "Review PR #42"
+ Registered "Refactor auth module"
FAQ
register always appends to the end. A supplied index is intentionally ignored — call move(id, index) after registering to reposition a ticket, which reindexes only the affected span.
createRegistry uses minimal reactivity by default for performance. Pass { reactive: true } to make keys(), values(), entries(), size, and per-ticket field reads reactive in templates and computeds.
createRegistry is the base ordered, keyed collection — registration, indexing, and lookup. createSelection extends it (through createModel) with selection state. Use createRegistry when you need to track items but not which are selected.
Pass { reactive: true } to make keys(), values(), entries(), size, and per-ticket field reads reactive directly on the registry. Reach for useProxyRegistry when you want event-driven snapshots, deep: true tracking, or reactivity without wrapping the tickets themselves.
Wrap them in batch(fn). Events queue until the callback returns and iteration subscribers are notified once, so a sequence of register / move / unregister calls settles once instead of per mutation. The iteration cache is still cleared per operation, and a reindex deferred by a removal drains when the batch returns, so survivors’ index is canonical once the outermost batch() returns.