What is the right way to unsubscribe to multiple snapshots in vuejs?
I have multiple components, and most of them have a snapshot to take advantage of firebase real time sync, the logout function is located in a navbar component, but once I logout from firebase, I got an error because I'm not unsubscribing from my snapshots, but how can I do this if all of them are on different components?
Is there a way to unsubscribe all snapshots at once?
Thanks in advance for your kind help.
To unsubscribe from a snapShot, you can use beforeDestroy . This gets called whenever you navigate away from this component. Inside you can call methods for unsubscribing from your snapShots.
For more information, see the Vue.js docs. https://v2.vuejs.org/v2/api/#beforeDestroy
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.