-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TRA | No listeners for event #4160
Comments
I have experienced this too |
I get this message when using the DragAndDrop configuration with OnFileDrop. However the functionality seems to work anyway. So I am not sure why the message pops up 🤔 |
Same bug. I had reviewed the code,you should EventsOn event which you emit... |
I have the same issue. This was not happening in version 2.9.2. |
Could someone please use |
Interestingly, this isn't a new issue introduced in 2.10.1 — it's actually been there all along. The only reason it's surfaced now is because the loglevel mechanism in 2.10.1 has stopped working as expected. Wails' event system supports event propagation in all directions: frontend ↔ frontend, frontend ↔ backend, backend ↔ backend. So when you call the following: runtime.EventsEmit(a.ctx, "update", "test")
If you're curious, you can follow this trail in the v2.10.1 source code to see where and why the log appears: runtime.EventsEmit(a.ctx, "update", "test")
// v2/pkg/runtime/events.go:46
func EventsEmit(ctx context.Context, eventName string, optionalData ...interface{}) {
events := getEvents(ctx)
events.Emit(eventName, optionalData...)
}
// v2/internal/frontend/runtime/events.go:57
func (e *Events) Emit(eventName string, data ...interface{}) {
e.notifyBackend(eventName, data...)
for _, thisFrontend := range e.frontend {
thisFrontend.Notify(eventName, data...)
}
}
// v2/internal/frontend/runtime/events.go:119
func (e *Events) notifyBackend(eventName string, data ...interface{}) {
e.notifyLock.Lock()
defer e.notifyLock.Unlock()
// Get list of event listeners
listeners := e.listeners[eventName]
if listeners == nil {
e.log.Trace("No listeners for event '%s'", eventName) // <- this is the message you're seeing
return
}
// ...
}
// v2/internal/frontend/desktop/windows/frontend.go:601
func (f *Frontend) Notify(name string, data ...interface{}) {
notification := EventNotify{
Name: name,
Data: data,
}
payload, err := json.Marshal(notification)
if err != nil {
f.logger.Error(err.Error())
return
}
f.ExecJS(`window.wails.EventsNotify('` + template.JSEscapeString(string(payload)) + `');`)
// <- this triggers the frontend’s EventsOn handler
} Conclusion:I don't think this is actually a bug. A simple improvement would be to make the log message more descriptive. For example, change it to: e.log.Trace("No backend listeners for event '%s'", eventName) |
Description
When using the
runtime.Eventsummit(a.ctx, "update", "test")
I receive a message in the terminal sayingTRA | No listeners for event 'update'
.But EventsEmit itself is working and I get the result on the frontend.
To Reproduce
Modify example func:
and modify web component:
Expected behaviour
I'm not sure if this is a mistake. Documentation on Events in Wails is extremely scarce.
This message not show in production mode
Screenshots
No response
Attempted Fixes
search in issues
System Details
Additional context
No response
The text was updated successfully, but these errors were encountered: