once
이 콘텐츠는 아직 번역되지 않았습니다.
Module @netwiv/api/event · Kind Function
import { once } from '@netwiv/api/event';Listens once to an emitted event to any {@link EventTargettarget}.
Signature
Section titled “Signature”function once<T>(event: EventName, handler: EventCallback<T>, options?: Options | undefined): Promise<UnlistenFn>Example
Section titled “Example”import { once } from '@netwiv/api/event';interface LoadedPayload { loggedIn: boolean, token: string}const unlisten = await once<LoadedPayload>('loaded', (event) => { console.log(`App is loaded, loggedIn: ${event.payload.loggedIn}, token: ${event.payload.token}`);});
// you need to call unlisten if your handler goes out of scope e.g. the component is unmountedunlisten();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.