Min*_*yen 16 firebase google-cloud-platform google-cloud-firestore
我是Google Cloud FireStore的新手.
Document对象具有onSnapshot函数调用,用于附加DocumentSnapshot事件的侦听器.
是否有删除该侦听器的函数(如offSnapshot)?如果不是,我该如何实施呢?
Sca*_*ami 39
对于web和node.js SDK,调用onSnapshot
返回一个函数,您需要将其保存在变量中,并在要删除侦听器时调用.
var unsubscribe = db.collection("cities").onSnapshot(function (querySnaphot) {
// do something with the data.
});
// Stop listening to changes
unsubscribe();
Run Code Online (Sandbox Code Playgroud)
其他SDK提供类似的功能.
有关参考,请参阅https://firebase.google.com/docs/firestore/query-data/listen#detach_a_listener.
归档时间: |
|
查看次数: |
12615 次 |
最近记录: |