index.computed
computed<T>(getter, name?): ReadonlySignal<T>
Creates a lazily-evaluated, memoized reactive computed signal derived from reactive sources.
| Name | Description |
|---|---|
T |
The return type of the computation. |
| Name | Type | Description |
|---|---|---|
getter |
() => T |
Pure function that computes the derived value from reactive dependencies. |
name? |
string |
Optional diagnostic name for debugging, telemetry, and observability tracking. |
A ReadonlySignal exposing the derived, cached .value.
Remarks
The computed primitive takes a pure evaluation function and automatically tracks any reactive
signals, domain stores, collections, or other computed signals accessed during its calculation.
It caches its output value until one of its tracked dependencies mutates, at which point it marks
itself as dirty and invalidates downstream subscribers. The getter is only re-executed on demand
when its .value is read.
Dependency tracking is dynamic: dependencies not read in the latest evaluation branch are cleaned up automatically.
Example