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, 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{}))
JS: EventsOn(eventName string, callback function(optionalData?: any))
EventsOff
このメソッドは、指定されたイベント名のイベントリスナー設定を解除します。引数のadditionalEventNames
を使用することで、複数のリスナーを一度に解除できます。
Go: EventsOff(ctx context.Context, eventName string, additionalEventNames ...string)
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{}))
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)
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{})
JS: EventsEmit(ctx context, optionalData function(optionalData?: any))