to-reactive
Reactive object view over a ref that holds an object.
| Package | @vizejs/composable/to-reactive |
| Own the source | vize lib pull composable:to-reactive |
| Runtime exports | toReactive |
| Gzip budget | 1024 B |
Usage
import { toReactive } from "@vizejs/composable/to-reactive";
Runtime contract
| Utility | Category | Stability | SSR | Hydration | Cleanup | Targets | Host globals | Uses |
|---|---|---|---|---|---|---|---|---|
toReactive |
reactivity | experimental | safe | stable | none | web, server, worker, native, desktop, terminal | — | — |
API
toReactive
Reactive object view over a ref that holds an object. Property reads and writes go to the ref's current object, so replacing the ref's value swaps the whole object behind a stable reactive proxy (handy for v-bind="state" or destructuring-free templates). Nested refs are unwrapped on read and written through on assignment. A non-ref object is simply passed to reactive. SSR-safe and nothing to dispose.
function toReactive<Value extends object>(objectRef: MaybeRef<Value>): Reactive<Value>
const state = ref({ name: "a" });
const view = toReactive(state);
state.value = { name: "b" };
view.name; // "b"