Skip to content

Function: computed()

ts
function computed<T>(fn: () => T, options?: SignalOptions<T>): ReadonlySignal<T>;

Defined in: @preact/signals-core:

Create a new signal that is computed based on the values of other signals.

The returned computed signal is read-only, and its value is automatically updated when any signals accessed from within the callback function change.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
fn() => TThe effect callback.
options?SignalOptions<T>-

Returns

ReadonlySignal<T>

A new read-only signal.