You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Parse @import lines in ::: example blocks to declare extra
dependencies for the @vue/repl playground. Auto-resolves to
esm.sh or accepts explicit URL overrides.
A multi-select bookmark manager demonstrating `createSelection` with `createContext` for provider/consumer separation. The provider owns the registry and exposes domain methods; the consumer handles UI and filtering.
84
+
85
+
```mermaid "Data Flow"
86
+
sequenceDiagram
87
+
participant C as BookmarkConsumer
88
+
participant P as BookmarkProvider
89
+
participant S as createSelection
90
+
91
+
C->>P: add(title, url, tags)
92
+
P->>S: register(ticket)
93
+
S-->>P: selectedIds updated
94
+
P-->>C: stats / pinned computed
95
+
C->>S: toggle(id)
96
+
S-->>C: isSelected ref updated
97
+
```
98
+
99
+
**File breakdown:**
100
+
101
+
| File | Role |
102
+
|------|------|
103
+
|`context.ts`| Defines `BookmarkInput` (extending `SelectionTicketInput`) and `BookmarkContext`, then creates the `[useBookmarks, provideBookmarks]` tuple |
104
+
|`BookmarkProvider.vue`| Creates the selection with `events: true`, wraps it with `useProxyRegistry` for reactive collection access, manages a separate `pinnedIds` Set, seeds initial bookmarks via `onboard`, and exposes mutation methods through context |
105
+
|`BookmarkConsumer.vue`| Calls `useBookmarks()` for data and methods; wraps the context with `useProxyRegistry` for reactive `values`; owns local UI state (filters, inputs) and derives `filtered` and `allTags` as computed |
106
+
|`bookmark-manager.vue`| Entry point—composes `BookmarkProvider` around `BookmarkConsumer`|
107
+
108
+
**Key patterns:**
109
+
110
+
-`events: true` + `useProxyRegistry` — enables reactive `proxy.values` so computeds like `filtered` and `allTags` update when bookmarks are added
111
+
-`pinnedIds` — a separate `shallowReactive(Set)` for pin state, following the same pattern as `selectedIds`
112
+
-`onboard()` — bulk-loads the initial bookmark set in a single batch
113
+
-`selection.register()` — adds a bookmark with custom fields (`url`, `tags`)
114
+
-`selection.toggle()` / `ticket.toggle()` — toggles selection from either the registry or the ticket
0 commit comments