mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 01:13:03 +08:00

* Add changelog. Fix zoom docs. Add Info.dev.plist info * Update build assets README.md * Update changelog * actions/checkout@v2 => v3 * Docs
45 lines
1.9 KiB
Plaintext
45 lines
1.9 KiB
Plaintext
---
|
|
sidebar_position: 2
|
|
---
|
|
|
|
# Events
|
|
|
|
The Wails runtime provides a unified events system, where events can be emitted or received by either Go or Javascript.
|
|
Optionally, data may be passed with the events. Listeners will receive the data in the local data types.
|
|
|
|
### EventsOn
|
|
|
|
This method sets up a listener for the given event name. When an event of type `eventName` is [emitted](#EventsEmit),
|
|
the callback is triggered. Any additional data sent with the emitted event will be passed to the callback.
|
|
|
|
Go: `EventsOn(ctx context.Context, eventName string, callback func(optionalData ...interface{}))`<br/>
|
|
JS: `EventsOn(eventName string, callback function(optionalData?: any))`
|
|
|
|
### EventsOff
|
|
|
|
This method unregisters the listener for the given event name, optionally multiple listeneres can be unregistered via `additionalEventNames`.
|
|
|
|
Go: `EventsOff(ctx context.Context, eventName string, additionalEventNames ...string)`<br/>
|
|
JS: `EventsOff(eventName string, ...additionalEventNames)`
|
|
|
|
### EventsOnce
|
|
|
|
This method sets up a listener for the given event name, but will only trigger once.
|
|
|
|
Go: `EventsOnce(ctx context.Context, eventName string, callback func(optionalData ...interface{}))`<br/>
|
|
JS: `EventsOnce(eventName string, callback function(optionalData?: any))`
|
|
|
|
### EventsOnMultiple
|
|
|
|
This method sets up a listener for the given event name, but will only trigger a maximum of `counter` times.
|
|
|
|
Go: `EventsOnMultiple(ctx context.Context, eventName string, callback func(optionalData ...interface{}), counter int)`<br/>
|
|
JS: `EventsOnMultiple(eventName string, callback function(optionalData?: any), counter int)`
|
|
|
|
### EventsEmit
|
|
|
|
This method emits the given event. Optional data may be passed with the event. This will trigger any event listeners.
|
|
|
|
Go: `EventsEmit(ctx context.Context, eventName string, optionalData ...interface{})`<br/>
|
|
JS: `EventsEmit(ctx context, optionalData function(optionalData?: any))`
|