Utilização

Notify JavaScript when a native device connection changes.

Este tipo é usado por event

tsx
// Notify JavaScript when a native device connection changes.
import { defineModule, event } from 'kuito';

export default defineModule('Accessory', {
  connected: event<{ name: string }>(),
  ios: { class: 'AccessoryModule' },
  android: { class: 'com.example.modules.accessory.AccessoryModule' },
});

// Implement startConnected/stopConnected on each platform. The consumer uses
// Accessory.connected.addListener(({ name }) => console.log(name)) and calls
// remove() on the returned subscription when observation is no longer needed.

Declaração do tipo

ts
export interface ModuleEvent<Payload> {
  /** The platform sends the event from the first listener until the last is removed. */
  addListener(listener: (payload: Payload) => void): EventSubscription;
}

Membros 1

NomeTipoObrigatórioDescrição
addListener(listener: (payload: Payload) => void) => EventSubscriptionSimThe platform sends the event from the first listener until the last is removed.
addListener — assinaturas de método

Assinaturas

ts
(listener: (payload: Payload) => void): EventSubscription

Parâmetros

NomeTipoObrigatórioDescrição
listener(payload: Payload) => voidSim—

Devolve

EventSubscription

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.