I have this problem: I'm doing a real-time query with firebase firestore in javascript, my code is as follows:
first = db.collection ("messages")
.where ("codeConversation", "==", codeConversation)
.orderBy ("date", "desc")
.limit (25);
first.onSnapshot (function (querySnapshot) {
// .. other execution
I read the documentation of how to stop it but I do not understand how to apply it says it should be the following:
var unsubscribe = db.collection ("cities")
.onSnapshot (function () {});
// ...
// Stop listening to changes
unsubscribe ();
I tried to replace the previous code with my own query in the following way to stop it but it did not work
var unsubscribe = db.collection ("messages")
.where ("codeConversation", "==", codeConversation)
.orderBy ("date", "desc")
.limit (25) .onSnapshot (function (querySnapshot) {
// ... other execution
// Stop listening to changes
unsubscribe ();