mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 22:20:06 +08:00

* fix(website): fix i18n configuration * feat: add i18n file to auto generate code * feat: move the crowdin configuration file to the website directory * feat(website): add crowdin dependencies and scripts * feat: add COC * feat: use escape hatch syntax to wrap JSX code in MDX files * feat: remove ach language * feat: generate default language configuration * feat: remove compare link * feat: add COC link * feat(website): update documentation * feat: use escape hatch syntax to wrap JSX code in MDX files * style: add prettier * style: format mdx files * chore: remove prettier command * feat: update en docs * feat: sync Chinese documents * feat: update doc * Update website/src/pages/coc.mdx Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
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))`
|