简体   繁体   中英

Unsubscribe to a firestore document snapshot listener

Is there a way to unsubscribe to snapshot updates for a listener I have put on a Firestore document? The documentation about this only shows how to unsubscribe to snapshot updates on a collection . It says an unsubscribe function is sent back when the snapshot listener is set. However, it does not look thats the case for snapshot listeners on a document. I dont get any unsubscribe function back, I only get an object that looks like this:

在此处输入图像描述

If it counts for anything, I am using the firebase emulator

The onSnapshot method returns a function that, when called, will unsubscribe:

const unsubscribe = firebase.firestore().doc('path/to/some/doc').onSnapshot(...);

// later
unsubscribe();

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.

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