notifications.watch
Calls listener with each notification that arrives while the app is in
the foreground, local or remote; it still shows. In a component it stops
when the component unmounts; elsewhere the returned subscription stops it.
Utilisation
Observe notifications received in the foreground.
// Observe notifications received in the foreground.
import { Text, notifications, signal } from 'kuito';
function Inbox() {
const latest = signal('');
// Stops when Inbox unmounts.
notifications.watch('received', (notification) => {
if (notification.remote) latest.value = notification.title ?? '';
});
return <Text>{latest.value}</Text>;
}Signatures
<E extends keyof Events>(event: E, listener: Events[E]): EventSubscriptionParamètres de type
| Nom | Contrainte | Par défaut |
|---|---|---|
E | "received" | — |
Paramètres
| Nom | Type | Requis | Description |
|---|---|---|---|
event | E | Oui | — |
listener | Events[E] | Oui | — |
Retourne
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.