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.
Utilização
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>;
}Assinaturas
<E extends keyof Events>(event: E, listener: Events[E]): EventSubscriptionParâmetros de tipo
| Nome | Restrição | Predefinição |
|---|---|---|
E | "received" | — |
Parâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
event | E | Sim | — |
listener | Events[E] | Sim | — |
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.