reactify
Turn a plain function into one that accepts refs/getters and returns a computed result.
| Package | @vizejs/composable/reactify |
| Own the source | vize lib pull composable:reactify |
| Runtime exports | reactify |
| Gzip budget | 256 B |
Usage
import { reactify } from "@vizejs/composable/reactify";
Runtime contract
| Utility | Category | Stability | SSR | Hydration | Cleanup | Targets | Host globals | Uses |
|---|---|---|---|---|---|---|---|---|
reactify |
reactivity | experimental | safe | stable | none | web, server, worker, native, desktop, terminal | — | — |
API
reactify
Turn a plain function into one that accepts refs/getters and returns a computed result. Arity and parameter names are preserved; each parameter additionally accepts Ref<T> or () => T. The computed re-runs the original function whenever a reactive argument changes. Pure derived state: SSR-safe and nothing to dispose.
function reactify<Arguments extends readonly unknown[], Result>( fn: (...args: Arguments) => Result, ): Reactified<Arguments, Result>
const add = reactify((left: number, right: number) => left + right);
const sum = add(count, 1); // ComputedRef<number>
reactify
function reactify( fn: (...args: readonly unknown[]) => unknown, ): (...args: readonly MaybeRefOrGetter<unknown>[]) => ComputedRef<unknown>