You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why exactly is the handlera required parameter to the off method in client.js? Sometimes you don't have the exact reference to the handler in memory and this can be problematic. Other times, you would just like to clean every handler up too, and in this case we should be able to call something like:
client.off('myEvent');
No?
The text was updated successfully, but these errors were encountered:
neemski
changed the title
Handler should be optional in client.off
Support removing multiple handlers from an event with client.off
Jul 12, 2018
Hi, can I get an update on this? This is really affecting the way we clean up handlers when we switch between ticket_sidebar and user_sidebar apps. Aka, when switching between those apps (on app.activated and app.deactivated), I'd like to bind/clean up all handlers without keeping reference to each bound handler.
For reference, my use case looks like this (using the app_scaffold):
// legacy_app.jsletApp={events: {'app.activated': 'activateHandler','app.deactivated': 'deactivateHandler',},activateHandler: function(){this.handlerList=[{evtName: 'myEvent',callback: this.myEventHandler,},
...
];this.handlerList.forEach((handler)=>{this.zafClient.on(handler.evtName,handler.callback);});},deactivateHandler: function(){// Would be really nice if I could just do// this.zafClient.off();// But I'll even settle for:this.handlerList.forEach((handler)=>{// Note that this.zafClient.off(handler.evtName, handler.callback); doesn't workthis.zafClient.off(handler.evtName);});},myEventHandler: function(){// ...},
...
};exportdefaultBaseApp.extend(App);
Hi @kneem, we don't have plans to implement this at the moment, but I don't see any issues with the idea itself. As this project is open-source you're free to submit a pull request. We'll review and merge as soon as time allows. Thanks, Daniel.
Hello!
Why exactly is the
handler
a required parameter to theoff
method inclient.js
? Sometimes you don't have the exact reference to thehandler
in memory and this can be problematic. Other times, you would just like to clean every handler up too, and in this case we should be able to call something like:No?
The text was updated successfully, but these errors were encountered: