Skip to content

listen

Module @netwiv/api/event · Kind Function

import { listen } from '@netwiv/api/event';

Listen to an emitted event to any {@link EventTargettarget}.

function listen<T>(event: EventName, handler: EventCallback<T>, options?: Options | undefined): Promise<UnlistenFn>
import { listen } from '@netwiv/api/event';
const unlisten = await listen<string>('error', (event) => {
console.log(`Got error, payload: ${event.payload}`);
});
// you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
unlisten();

Upstream since 1.0.0


Descriptions come from the pinned @tauri-apps/api@2.11.1 declarations (MIT OR Apache-2.0); imports are shown with @netwiv/api paths.