Derived
A value computed from another as it moves.
Usage
Dismiss and observe the keyboard
This type is used by 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>
);
}Type declaration
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>;
}Members 2
| Name | Type | Required | Description |
|---|---|---|---|
map | <U>(fn: (value: T) => U) => Derived<U> | Yes | A value computed from this one, on the UI thread. |
valuereadonly | T | Yes | — |
map — method signatures
Signatures
<U>(fn: (value: T) => U): Derived<U>Type parameters
| Name | Constraint | Default |
|---|---|---|
U | — | — |
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
fn | (value: T) => U | Yes | — |
Returns
Derived<U>
Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.