
useProxyRegistry
A reactive proxy wrapper for registry collections that automatically updates refs when items are registered or unregistered.
Usage
The useProxyRegistry composable creates reactive objects that automatically sync with a registry’s state. It listens for registry changes and updates the reactive properties accordingly, making it ideal for template-driven UIs that need to react to registry mutations.
Important: The registry must have events: true enabled for the proxy to receive updates.
import { useRegistry, useProxyRegistry } from '@vuetify/v0'
const registry = useRegistry({ events: true })
const proxy = useProxyRegistry(registry)
registry.register({ value: 'Item 1' })
registry.register({ value: 'Item 2' })
console.log(proxy.size) // 2
console.log(proxy.keys) // [id1, id2]API
| Composable | Description |
|---|---|
| useRegistry→ | The underlying registry system |
| useSelection→ | Selection-enabled registries |
| useTokens→ | Token management with registries |
useProxyRegistry
Type
interface ProxyRegistryOptions { deep?: boolean } interface ProxyRegistryContext<Z extends RegistryTicket = RegistryTicket> { keys: ID[] values: Z[] entries: [ID, Z][] size: number } function useProxyRegistry< Z extends RegistryTicket = RegistryTicket, > ( registry: RegistryContext<Z>, options?: ProxyRegistryOptions, ): ProxyRegistryContext<Z>Details
Creates a reactive proxy that wraps a registry’s collection data in reactive objects. The proxy automatically subscribes to the registry’s
registerandunregisterevents (requiresevents: trueon the registry) and updates the reactive properties synchronously whenever the registry changes.By default, the proxy uses shallow reactivity (
shallowReactive) for performance. Enable thedeepoption if you need deep reactivity for nested object mutations.The proxy automatically cleans up event listeners via
onScopeDispose, preventing memory leaks when components are unmounted.Parameters
registry: A registry instance created withuseRegistry({ events: true })options(optional):deep: Iftrue, usesreactive()for deep reactivity instead ofshallowReactive(). Defaults tofalse.
Returns
A reactive proxy object containing:
keys: Array of all registry IDsvalues: Array of all registry ticketsentries: Array of all [ID, ticket] tuplessize: Count of registered items
Example
import { useRegistry, useProxyRegistry } from '@vuetify/v0' import { watchEffect } from 'vue' const registry = useRegistry({ events: true }) const proxy = useProxyRegistry(registry) watchEffect(() => { console.log(`Registry has ${proxy.size} items`) }) registry.register({ value: 'First' }) // Logs: Registry has 1 items registry.register({ value: 'Second' }) // Logs: Registry has 2 items