EventSubscription
A subscription to a native event, which remove() ends.
Utilização
Observe compass readings and stop when the screen unmounts.
// Observe compass readings and stop when the screen unmounts.
import { Text, onMount, signal, location, type EventSubscription } from 'kuito';
export function Compass() {
const heading = signal('Waiting for compass');
onMount(() => {
let disposed = false;
let subscription: EventSubscription | undefined;
void location
.watchHeading((value) => {
heading.value = JSON.stringify(value);
})
.then((value) => {
if (disposed) value.remove();
else subscription = value;
})
.catch((error) => {
heading.value = String(error);
});
return () => {
disposed = true;
subscription?.remove();
};
});
return <Text>{heading.value}</Text>;
}Declaração do tipo
export interface EventSubscription {
remove(): void;
}Membros 1
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
remove | () => void | Sim | — |
remove — assinaturas de método
Assinaturas
(): voidParâmetros
Sem parâmetros.
Devolve
void
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.