Skip to content

Commit 7837884

Browse files
committed
docs(reactivity): fix pattern 1 to use registry.collection for proper reactivity
1 parent c4ea15e commit 7837884

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

apps/docs/src/pages/guide/fundamentals/reactivity.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,22 @@ import { createRegistry } from '@vuetify/v0'
170170

171171
const registry = createRegistry({ reactive: true })
172172

173-
// Now collection access is reactive
174-
registry.values() // Triggers reactivity
175-
registry.size // Triggers reactivity
173+
// The collection Map is now shallowReactive
174+
registry.collection.size // Reactive
175+
registry.collection.values() // Reactive iteration
176176
```
177177

178178
```vue playground
179179
<script setup>
180+
import { computed } from 'vue'
180181
import { createRegistry } from '@vuetify/v0'
181182
182183
const registry = createRegistry({ reactive: true })
183184
185+
// Use computed to access reactive collection
186+
const items = computed(() => Array.from(registry.collection.values()))
187+
const size = computed(() => registry.collection.size)
188+
184189
let count = 0
185190
function onAdd() {
186191
registry.register({
@@ -192,17 +197,17 @@ registry.size // Triggers reactivity
192197
193198
<template>
194199
<button @click="onAdd">Add Item</button>
195-
<p>Count: {{ registry.size }}</p>
200+
<p>Count: {{ size }}</p>
196201
<ul>
197-
<li v-for="item in registry.values()" :key="item.id">
202+
<li v-for="item in items" :key="item.id">
198203
{{ item.value }}
199204
</li>
200205
</ul>
201206
</template>
202207
```
203208

204209
> [!TIP]
205-
> The `reactive` option uses `shallowReactive` internally—top-level changes trigger updates, but nested object mutations won't.
210+
> The `reactive` option wraps the internal `collection` Map with `shallowReactive`. Access `registry.collection` directly for reactive tracking.
206211
207212
### Pattern 2: Events
208213

0 commit comments

Comments
 (0)