简体   繁体   English

取消订阅多个 Firestore 快照 VueJS

[英]Unsubscribe multiple firestore snapshots VueJS

What is the right way to unsubscribe to multiple snapshots in vuejs?在 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? 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快照,但是如果它们都在不同的组件上,我该怎么做呢?

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 .要取消订阅快照,您可以使用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.有关详细信息,请参阅 Vue.js 文档。 https://v2.vuejs.org/v2/api/#beforeDestroy https://v2.vuejs.org/v2/api/#beforeDestroy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM