Skip to content

Commit 6ff07f8

Browse files
committed
docs: wrap registry examples in useProxyRegistry + warn on footgun
Three examples (use-features, create-breadcrumbs basic + file-explorer) now wrap their registries through useProxyRegistry and iterate proxy.values instead of registry.values(), matching the component-layer guidance for template iteration. Also adds a WARNING callout in the composables index explaining why passing a reactive registry directly to v-for breaks dep tracking. Pairs with the composable source refactor in 8ca8557.
1 parent 8ca8557 commit 6ff07f8

4 files changed

Lines changed: 15 additions & 9 deletions

File tree

apps/docs/src/examples/composables/create-breadcrumbs/basic.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<script setup lang="ts">
2-
import { computed } from 'vue'
3-
import { createBreadcrumbs } from '@vuetify/v0'
2+
import { toRef } from 'vue'
3+
import { createBreadcrumbs, useProxyRegistry } from '@vuetify/v0'
44
55
const breadcrumbs = createBreadcrumbs()
6+
const proxy = useProxyRegistry(breadcrumbs)
67
78
const path = [
89
{ text: 'Home' },
@@ -15,7 +16,7 @@
1516
1617
breadcrumbs.onboard(path)
1718
18-
const items = computed(() => breadcrumbs.values())
19+
const items = toRef(() => proxy.values)
1920
2021
function reset () {
2122
breadcrumbs.clear()

apps/docs/src/examples/composables/create-breadcrumbs/file-explorer/FileExplorer.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
2-
import { computed } from 'vue'
3-
import { createBreadcrumbs } from '@vuetify/v0'
2+
import { computed, toRef } from 'vue'
3+
import { createBreadcrumbs, useProxyRegistry } from '@vuetify/v0'
44
import { tree } from './tree'
55
66
import type { BreadcrumbTicketInput } from '@vuetify/v0'
@@ -12,10 +12,11 @@
1212
}
1313
1414
const breadcrumbs = createBreadcrumbs<FileBreadcrumbTicketInput>()
15+
const proxy = useProxyRegistry(breadcrumbs)
1516
1617
const current = computed(() => breadcrumbs.selectedValue.value ?? tree)
1718
const children = computed(() => current.value.children ?? [])
18-
const items = computed(() => breadcrumbs.values())
19+
const items = toRef(() => proxy.values)
1920
2021
function isFolder (node: FolderNode) {
2122
return !!node.children

apps/docs/src/examples/composables/use-features/feature-flags.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { createFeaturesContext, useFeatures } from '@vuetify/v0'
2+
import { createFeaturesContext, useFeatures, useProxyRegistry } from '@vuetify/v0'
33
import { toRef } from 'vue'
44
55
const [, provideFeatures] = createFeaturesContext({
@@ -16,16 +16,17 @@
1616
provideFeatures()
1717
1818
const features = useFeatures()
19+
const proxy = useProxyRegistry(features)
1920
20-
const tickets = toRef(() => [...features.values()])
21+
const tickets = toRef(() => proxy.values)
2122
const enabled = toRef(() => features.selectedIds.size)
2223
</script>
2324

2425
<template>
2526
<div class="space-y-4">
2627
<div class="flex items-center justify-between">
2728
<p class="text-xs text-on-surface-variant">
28-
{{ enabled }} / {{ features.size }} features enabled
29+
{{ enabled }} / {{ proxy.size }} features enabled
2930
</p>
3031
<div class="flex gap-1.5">
3132
<button

apps/docs/src/pages/composables/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ For direct Vue reactivity on the collection and tickets themselves, pass `reacti
8282
</template>
8383
```
8484

85+
> [!WARNING]
86+
> Don't pass a registry directly to `v-for`. Pair `events: true` with `useProxyRegistry()` at the component boundary — the proxy exposes reactive `keys`, `values`, `entries`, and `size` properties that templates can iterate safely. Reading `.values()` from a `reactive: true` registry in a `v-for` breaks Vue's dep tracking because the internal cache invalidates on every mutation.
87+
8588
Unlike events (which fire callbacks) or `useProxyRegistry` (which wraps with computed refs), `reactive: true` makes the underlying Map and each ticket `shallowReactive`. Use it when you need Vue's dependency tracking at the ticket level.
8689

8790
### useProxyModel for v-model Binding

0 commit comments

Comments
 (0)