computed
A signal derived from the signals fn reads: computed on first read, and
again only once one of them changed.
Usage
Calculate a cart total
import { Button, Text, VStack, computed, signal } from 'kuito';
export function Cart() {
const quantity = signal(1);
const total = computed(() => quantity.value * 12);
return (
<VStack gap={12}>
<Text>{`${quantity.value} tickets: €${total.value}`}</Text>
<Button onPress={() => quantity.value++}>Add a ticket</Button>
</VStack>
);
}Signatures
<T>(fn: () => T): ReadonlySignal<T>Type parameters
| Name | Constraint | Default |
|---|---|---|
T | — | — |
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
fn | () => T | Yes | — |
Returns
Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.