useProjection<
T
>(
registry: MaybeRefOrGetter<ChannelRegistry | null | undefined>,
specFactory: () =>| Name | Type | Description |
|---|---|---|
registry* | MaybeRefOrGetter<ChannelRegistry | null | undefined> | |
specFactory* | () => ProjectionSpec<T> | |
key* | MaybeRefOrGetter<string> | |
initialValue* | T |
Vue primitive that composes ChannelRegistry.acquire with Vue's reactivity system.
Contract (mirrors the React useProjection hook but adapted to
Vue's setup + onScopeDispose lifecycle):
setup() (or whenever registry / key change) the
composable acquires a ref-counted projection from the registry
and subscribes to its store. Vue re-renders automatically
whenever the store's snapshot changes.onScopeDispose (or when registry / key change) the
previous acquisition is released. If this was the last consumer
of that spec, the registry closes the underlying server
subscription.registry is null/undefined the composable stays at
initialValue. This is the happy path for root-served
projections (useMessages, useToolCalls, useValues) which
delegate to the always-on root store instead of acquiring a new
registry projection.registry and key accept MaybeRefOrGetter so selector
composables can pass a reactive target (e.g. a computed subagent
snapshot) and have the projection rebind automatically.
Returns a Readonly<ShallowRef<T>> so templates auto-unwrap and
scripts can computed(() => proj.value). The underlying ref is
shallowRef — consumers that mutate the snapshot get undefined
behaviour; stream projections should always be treated as
immutable snapshots.