The event system allows you to emit events to the backend and listen to events from it.
This package is also accessible with window.__TAURI__.event when tauri.conf.json > build > withGlobalTauri is set to true.
Interfaces#
Type aliases#
EventCallback#
Ƭ EventCallback<T>: (event: Event<T>) => void
Type parameters#
| Name |
|---|
T |
Type declaration#
▸ (event): void
Parameters#
| Name | Type |
|---|---|
event | Event<T> |
Returns#
void
Defined in#
EventName#
Ƭ EventName: LiteralUnion<"tauri://update" | "tauri://update-available" | "tauri://update-install" | "tauri://update-status" | "tauri://resize" | "tauri://move" | "tauri://close-requested" | "tauri://destroyed" | "tauri://focus" | "tauri://blur" | "tauri://scale-change" | "tauri://menu" | "tauri://file-drop" | "tauri://file-drop-hover" | "tauri://file-drop-cancelled", string>
Defined in#
UnlistenFn#
Ƭ UnlistenFn: () => void
Type declaration#
▸ (): void
Returns#
void
Defined in#
Functions#
emit#
▸ emit(event, payload?): Promise<void>
Emits an event to the backend.
Parameters#
| Name | Type | Description |
|---|---|---|
event | string | Event name |
payload? | string | - |
Returns#
Promise<void>
Defined in#
listen#
▸ listen<T>(event, handler): Promise<UnlistenFn>
Listen to an event from the backend.
Type parameters#
| Name |
|---|
T |
Parameters#
| Name | Type | Description |
|---|---|---|
event | EventName | Event name |
handler | EventCallback<T> | Event handler callback |
Returns#
Promise<UnlistenFn>
A promise resolving to a function to unlisten to the event.
Defined in#
once#
▸ once<T>(event, handler): Promise<UnlistenFn>
Listen to an one-off event from the backend.
Type parameters#
| Name |
|---|
T |
Parameters#
| Name | Type | Description |
|---|---|---|
event | EventName | Event name |
handler | EventCallback<T> | Event handler callback |
Returns#
Promise<UnlistenFn>
A promise resolving to a function to unlisten to the event.