I’m using appEvents to trigger widget re-rendering after message-bus notifications. This is working ok, but I can’t find any way to “de-register” an appEvent listener once a widget is no longer required.
I setup the listener in the widget’s defaultState()
function, in the same way as is done in core widgets:
Ideally then I want to be able to call
appEvents.off("whosonline:changed")
when the widget is no longer needed. Otherwise the array of listeners keeps growing and eventually explodes
https://meta.discourse.org/t/whos-online-plugin/52345/90?u=david_taylor
I was hoping to use the widget destroy
function, but it doesn’t look like it’s actually wired up to anything. The default implementation is a console message, and I don’t ever see that in the console.
@eviltrout is there some way to run logic when a widget is thrown away? Or is there another way I should be approaching this problem?