app.watch
Calls listener when the system warns that memory runs low. In a
component it stops when the component unmounts; elsewhere the returned
subscription stops it.
Verwendung
Refresh on return and release cached data
import { Button, app, watch } from 'kuito';
declare function refresh(): void;
const cache = new Map<string, ArrayBuffer>();
app.state.value; // 'active' | 'background' | 'inactive'
export function Feed() {
// Both follow the platform until the component unmounts.
watch(app.state, (state) => {
if (state === 'active') refresh();
});
app.watch('memoryWarning', () => cache.clear());
return <Button onPress={() => void app.openSettings()}>Open Settings</Button>;
}Signaturen
<E extends keyof Events>(event: E, listener: Events[E]): EventSubscriptionTypparameter
| Name | Einschränkung | Standard |
|---|---|---|
E | "memoryWarning" | — |
Parameter
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
event | E | Ja | — |
listener | Events[E] | Ja | — |
Rückgabe
Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.