From 0e0db50dea561ecf554a5a5e21a2f833c8e6bf61 Mon Sep 17 00:00:00 2001 From: Travis McLane Date: Fri, 26 Apr 2024 13:47:08 -0500 Subject: [PATCH] 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. --- v3/pkg/application/application.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/v3/pkg/application/application.go b/v3/pkg/application/application.go index dbd71674..2ed1b4ed 100644 --- a/v3/pkg/application/application.go +++ b/v3/pkg/application/application.go @@ -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()