Derived
A value computed from another as it moves.
Utilisation
Dismiss and observe the keyboard
Ce type est utilisé par 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>
);
}Déclaration du type
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>;
}Membres 2
| Nom | Type | Requis | Description |
|---|---|---|---|
map | <U>(fn: (value: T) => U) => Derived<U> | Oui | A value computed from this one, on the UI thread. |
valuelecture seule | T | Oui | — |
map — signatures de méthode
Signatures
<U>(fn: (value: T) => U): Derived<U>Paramètres de type
| Nom | Contrainte | Par défaut |
|---|---|---|
U | — | — |
Paramètres
| Nom | Type | Requis | Description |
|---|---|---|---|
fn | (value: T) => U | Oui | — |
Retourne
Derived<U>
Généré depuis les déclarations TypeScript publiques : signatures, props et valeurs par défaut viennent de la source vérifiée, les descriptions de sa JSDoc. Aucune valeur par défaut n'est inventée.