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
Not sure if this is a bug or if I'm doing somethig wrong.
I subscribe to an event (a channel in this case) in the activate() hook. When I route to the same view, but with different parameter (like id), the activate hook is called again and then I have two (2) subscriptions on the channel (and then 3 and then 4 etc.). Not sure if it's clear what I mean..? :)
Anyway, I moved the subscribe() call to the constructor instead, and then it works. Not sure if this is the right way to do it? Or should there be an unsubscribe function which could be called in the deactivate hook?
Thanks!
The text was updated successfully, but these errors were encountered:
When you subscribe, the EA will return an object to you with a dispose method so that you can later call it to unsubscribe or dispose the subscription. I recommend that you simply store the subscription object and call dispose in the deactivate callback. This is usually a pattern that works well.
Not sure if this is a bug or if I'm doing somethig wrong.
I subscribe to an event (a channel in this case) in the activate() hook. When I route to the same view, but with different parameter (like id), the activate hook is called again and then I have two (2) subscriptions on the channel (and then 3 and then 4 etc.). Not sure if it's clear what I mean..? :)
Anyway, I moved the subscribe() call to the constructor instead, and then it works. Not sure if this is the right way to do it? Or should there be an unsubscribe function which could be called in the deactivate hook?
Thanks!
The text was updated successfully, but these errors were encountered: