computed
A signal derived from the signals fn reads: computed on first read, and
again only once one of them changed.
Utilização
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>
);
}Assinaturas
<T>(fn: () => T): ReadonlySignal<T>Parâmetros de tipo
| Nome | Restrição | Predefinição |
|---|---|---|
T | — | — |
Parâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
fn | () => T | Sim | — |
Devolve
Gerado a partir das declarações TypeScript públicas: assinaturas, props e predefinições vêm da fonte verificada, as descrições da sua JSDoc. Nenhuma predefinição é inventada.