once
once<
T>(event,handler,options?):Promise<UnlistenFn>
Defined in: event.ts:157
Listens once to an emitted event to any target.
T
Event name. Must include only alphanumeric characters, -, /, : and _.
Event handler callback.
Event listening options.
Promise<UnlistenFn>
A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
import { once } from '@tauri-apps/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();1.0.0
© 2025 Tauri Contributors. CC-BY / MIT