# computed

`computed(compute, options?)` returns a readonly [`Signal`](/reference/types/canvas-runtime/#signal).
It evaluates lazily, caches its value, and replaces its synchronous dependency
edges after each successful evaluation. Equality defaults to `Object.is`.

Computed functions cannot write signals, including equality no-ops, and cycles
are rejected with a diagnostic.

See the [signals and scheduling contract](https://github.com/benlesh/pibbl/blob/main/docs/design/signals-and-scheduling-contract.md).

Related types: [`Signal`](/reference/types/canvas-runtime/#signal),
[`SignalOptions`](/reference/types/canvas-runtime/#signaloptions).

## API details from source

<span id="api-computed"></span>

Creates a lazy, cached readonly signal whose dependencies are tracked during evaluation.

```ts
computed: <T>(compute: () => T, options?: SignalOptions<T>) => Signal<T>
```

Related API: [computed](/reference/functions/computed/), [SignalOptions](/reference/types/canvas-runtime/#signaloptions), [Signal](/reference/types/canvas-runtime/#signal).

### Parameters

- **`compute`** — Synchronous calculation whose signal reads become dependencies.

- **`options`** — Equality comparison and optional diagnostic name. See [SignalOptions](/reference/types/canvas-runtime/#signaloptions).

### Returns

A readonly, lazy, cached signal that recomputes when its dependencies change. See
[Signal](/reference/types/canvas-runtime/#signal) .

### See also

[SignalOptions](/reference/types/canvas-runtime/#signaloptions)

[Signal](/reference/types/canvas-runtime/#signal)

[View source — packages/core/src/lib/signals/graph.ts:673](/source/packages/core/src/lib/signals/graph-ts/#L673)

## Implementation guidance for agents

Read the [Authoring, signals, and lifecycle companion](/agents/topics/lifecycle/) for ownership, adaptation, failure modes, and verification. [Agent start](/agents/) provides the version-selection workflow.

## Complete minimal examples

- [Read and update signals](/minimal-examples/lifecycle/signals/): Use writable, readonly, and computed values with synchronous batching. [Plain source](/minimal/lifecycle/signals.ts)
## Documentation version

Documentation built with @pibbl/core 0.0.2, revision 272a94a. ALPHA — NOT FOR PRODUCTION USE.
