[**Documentation**](../../../../README)

***

[Documentation](../../../../README) / [@zerotal/flow](../../README) / [index](../README) / computed

# Function: computed()

> **computed**\<`This`, `Return`\>(`getter`, `context`): (`this`) => `Return`

Defined in: [flow/src/decorators.ts:352](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/flow/src/decorators.ts#L352)

Marks a getter as computed — a value derived from other state, excluded from the snapshot.

## Type Parameters

### This

`This`

### Return

`Return`

## Parameters

### getter

(`this`) => `Return`

### context

`ClassGetterDecoratorContext`\<`This`, `Return`\>

## Returns

(`this`) => `Return`

## Remarks

A computed getter is not serialized and is not client-writable; it renders as static
server-produced text. The result is memoized for the duration of a single render pass
(Livewire-style per-request caching): an expensive getter read several times in one template
runs once. The cache is scoped to the active render (see `_renderFlowPage`), so reads
outside rendering always recompute and never go stale. Apply only to a getter — a field-style
decorator on it is rejected; conversely `@computed` on a non-getter is a TypeScript error.

## Example

```tsx
class Cart extends Component {
  @expose items: LineItem[] = [];

  @computed get total(): number {
    return this.items.reduce((sum, i) => sum + i.price * i.qty, 0);
  }
}
```
