mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
ensure event listener is activated (hooks)
The OS X delegate listener for an event is only activated if the `on` call is made for the event id. This is an optimization to prevent flooding the application with events that the application does not actually care about. The `impl.on` call is what activates the response handler for the event in question. This logic was missing in the RegisterHooks() function but is present in the `On()` function. In the case of using `On()` first followed by `RegisterHooks()` things work correctly.
This commit is contained in:
@@ -397,6 +397,9 @@ func (a *App) RegisterHook(eventType events.ApplicationEventType, callback func(
|
||||
callback: callback,
|
||||
}
|
||||
a.applicationEventHooks[eventID] = append(a.applicationEventHooks[eventID], thisHook)
|
||||
if a.impl != nil {
|
||||
go a.impl.on(eventID)
|
||||
}
|
||||
|
||||
return func() {
|
||||
a.applicationEventHooksLock.Lock()
|
||||
|
||||
Reference in New Issue
Block a user