Derived
A value computed from another as it moves.
Utilização
Dismiss and observe the keyboard
Este tipo é usado por keyboard.frame
import { Box, Button, Text, VStack, keyboard } from 'kuito';
export default function KeyboardState() {
keyboard.frame.value; // { screenX, screenY, width, height } or null
// In a component, until it unmounts; elsewhere, until remove().
keyboard.watch('didShow', (event) => console.log(event.frame.height, event.duration));
return (
<VStack>
<Text>{keyboard.visible.value ? 'typing' : ''}</Text>
{/* Rides on the keyboard. */}
<Box translateY={keyboard.height.map((height) => -height)} />
<Button onPress={() => keyboard.dismiss()}>Done</Button>
</VStack>
);
}Declaração do tipo
export interface Derived<T> extends Readable<T> {
readonly __kuitoDerived: DerivedSpec;
/** A value computed from this one, on the UI thread. */
map<U>(fn: (value: T) => U): Derived<U>;
}Membros 2
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
map | <U>(fn: (value: T) => U) => Derived<U> | Sim | A value computed from this one, on the UI thread. |
valuesó de leitura | T | Sim | — |
map — assinaturas de método
Assinaturas
<U>(fn: (value: T) => U): Derived<U>Parâmetros de tipo
| Nome | Restrição | Predefinição |
|---|---|---|
U | — | — |
Parâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
fn | (value: T) => U | Sim | — |
Devolve
Derived<U>
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.