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.
Usage
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' },
});Signatures
<T>(): ReadonlySignal<T>Type parameters
| Name | Constraint | Default |
|---|---|---|
T | — | — |
Parameters
No parameters.
Returns
Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.