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 parametersName |
---|
T |
#
Type declaration▸ (event
): void
#
ParametersName | Type |
---|---|
event | Event <T > |
#
Returnsvoid
#
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
#
Returnsvoid
#
Defined in#
Functions#
emit▸ emit(event
, payload?
): Promise
<void
>
Emits an event to the backend.
#
ParametersName | Type | Description |
---|---|---|
event | string | Event name |
payload? | string | - |
#
ReturnsPromise
<void
>
#
Defined in#
listen▸ listen<T
>(event
, handler
): Promise
<UnlistenFn
>
Listen to an event from the backend.
#
Type parametersName |
---|
T |
#
ParametersName | Type | Description |
---|---|---|
event | EventName | Event name |
handler | EventCallback <T > | Event handler callback |
#
ReturnsPromise
<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 parametersName |
---|
T |
#
ParametersName | Type | Description |
---|---|---|
event | EventName | Event name |
handler | EventCallback <T > | Event handler callback |
#
ReturnsPromise
<UnlistenFn
>
A promise resolving to a function to unlisten to the event.