useComputed
useComputed(compute, dependencies?, options?) returns one stable readonly
Signal for a mounted component hook slot.
Signal reads inside compute are tracked dynamically. The optional dependency
array lists captured non-signal values and compares its positions with
Object.is.
The formula remains lazy. Dependency changes are adopted only after a successful render, and result equality prevents unnecessary downstream invalidation. A retained signal continues using its last successfully committed formula after its owner is removed.
Related types: Signal and
SignalOptions.
API details from source
Section titled “API details from source”
Creates one component-owned lazy computed signal for a mounted hook slot.
useComputed: <T>(compute: () => T, dependencies?: readonly unknown[], options?: SignalOptions<T>) => Signal<T>Related API: useComputed, SignalOptions, Signal.
Parameters
Section titled “Parameters”-
compute— Synchronous calculation whose signal reads are tracked. -
dependencies— Values controlling replacement of the captured computation. -
options— Equality comparison and optional diagnostic name. See SignalOptions.
Returns
Section titled “Returns”A mount-owned readonly computed signal. See Signal.
See also
Section titled “See also”View source — packages/core/src/lib/hooks/use-computed.ts:43
Implementation guidance for agents
Section titled “Implementation guidance for agents”Read the Authoring, signals, and lifecycle companion for ownership, adaptation, failure modes, and verification. Agent start provides the version-selection workflow.
Complete minimal examples
Section titled “Complete minimal examples”- Component-owned state and reactions: Click to update a signal, derive a value, and publish an imperative effect after commit. Plain source
Documentation version
Section titled “Documentation version”Documentation built with @pibbl/core 0.0.2, revision 272a94a. ALPHA — NOT FOR PRODUCTION USE.