toValue#

Resolve a MaybeSignal<T> to its current value: call getters, unwrap signal-shaped { value } handles (primitive signals, computeds, toSignal/toSignals views), pass everything else through. Cross-platform — import from @sigx/use.

TypeScript
import { signal, computed } from 'sigx';
import { toValue } from '@sigx/use';

toValue(42);                 // 42
toValue(signal(42));         // 42
toValue(computed(() => 42)); // 42
toValue(() => 42);           // 42

This is the resolver behind every composable's MaybeSignal argument — reach for it when you build your own. Reading inside a reactive context tracks as usual — toValue adds no untrack, so a reactive source makes the surrounding effect/computed react to it.

A plain (non-signal) object that happens to have a value property is passed through as-is, not unwrapped. If you mean it as a value, hand it over as a getter: () => obj.

Signature#

TypeScript
function toValue<T>(source: MaybeSignal<T>): T;

Platform: everywhere.

See also#