live
Declares platform state an app reads as a signal: level: live<number>().
Unwatched, each read asks the platform on the JS thread; watched,
start<Name> gets the signal on the main thread and sets each change.
Utilização
Define the TypeScript contract
import { defineModule, fn, live } from 'kuito';
export type Reading = { level: number; charging: boolean };
export default defineModule('Battery', {
/** Low Power Mode on iOS, Battery Saver on Android. */
lowPower: live<boolean>(),
/** The charge from 0 to 1, or -1 when unknown. */
read: fn.main<() => Promise<Reading>>(),
ios: { class: 'BatteryModule' },
android: { class: 'com.example.myapp.modules.battery.BatteryModule' },
});Assinaturas
<T>(): ReadonlySignal<T>Parâmetros de tipo
| Nome | Restrição | Predefinição |
|---|---|---|
T | — | — |
Parâmetros
Sem parâmetros.
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.