[英]Unsubscribe multiple firestore snapshots 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快照,但是如果它們都在不同的組件上,我該怎么做呢?
有沒有辦法一次取消訂閱所有快照?
提前感謝您的幫助。
要取消訂閱快照,您可以使用beforeDestroy 。 每當您離開此組件時,都會調用它。 在里面,您可以調用從快照中取消訂閱的方法。
有關詳細信息,請參閱 Vue.js 文檔。 https://v2.vuejs.org/v2/api/#beforeDestroy
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.