Skip to main content

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#
NameType
eventEvent<T>
Returns#

void

Defined in#

event.ts:45


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#

event.ts:26


UnlistenFn#

Ƭ UnlistenFn: () => void

Type declaration#

▸ (): void

Returns#

void

Defined in#

event.ts:47

Functions#

emit#

emit(event, payload?): Promise<void>

Emits an event to the backend.

Parameters#

NameTypeDescription
eventstringEvent name
payload?string-

Returns#

Promise<void>

Defined in#

event.ts:113


listen#

listen<T>(event, handler): Promise<UnlistenFn>

Listen to an event from the backend.

Type parameters#

Name
T

Parameters#

NameTypeDescription
eventEventNameEvent name
handlerEventCallback<T>Event handler callback

Returns#

Promise<UnlistenFn>

A promise resolving to a function to unlisten to the event.

Defined in#

event.ts:73


once#

once<T>(event, handler): Promise<UnlistenFn>

Listen to an one-off event from the backend.

Type parameters#

Name
T

Parameters#

NameTypeDescription
eventEventNameEvent name
handlerEventCallback<T>Event handler callback

Returns#

Promise<UnlistenFn>

A promise resolving to a function to unlisten to the event.

Defined in#

event.ts:96