Event name. Must include only alphanumeric characters, -
, /
, :
and _
.
Optional
payload: unknownEvent payload.
Emits an event to all EventTarget|targets matching the given target.
Label of the target Window/Webview/WebviewWindow or raw EventTarget object.
Event name. Must include only alphanumeric characters, -
, /
, :
and _
.
Optional
payload: unknownEvent payload.
Listen to an emitted event to any EventTarget|target.
Event name. Must include only alphanumeric characters, -
, /
, :
and _
.
Event handler callback.
Optional
options: OptionsEvent listening options.
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.
Listens once to an emitted event to any EventTarget|target.
Event name. Must include only alphanumeric characters, -
, /
, :
and _
.
Event handler callback.
Optional
options: OptionsEvent listening options.
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 unmounted
unlisten();
Emits an event to all EventTarget|targets.