core / const
value
Extracts the plain value from a signal, non-signal, or plain value.
Extracts the plain value from a signal, non-signal, or plain value.
This utility function unwraps signalified objects to get their underlying plain values. If the input is already a plain value, it returns it as-is.
Signature
export const value = <T>(input: MaybeSignalValue<T>): T =>
valueIsSignalifiedObject(input)
? (input as SignalifiedObject<T>).value
: (input as T);
Type Parameters
- The type of the plain value
Parameters
input: A signal, non-signal, or plain value
Returns
The unwrapped plain value
Remarks
- Does not trigger dependency tracking
- Works with
nullandundefined - Works with nested structures
Examples
const count = signal(42);
const nonSig = getNonSignalObject("hello");
value(count); // 42
value(nonSig); // "hello"
value(100); // 100
See Also
- MaybeSignalValue - For the input type
- SignalifiedObject - For signalified object types