Stop a scam in real time on firebase firestore

0

I have this problem: I am doing a real-time query to firebase firestore in javascript my code is this:

  first = db.collection("messages")
    .where("codeConversation", "==", codeConversation)
    .orderBy("date", "desc")
    .limit(25);

  first.onSnapshot(function (querySnapshot) {

//.. demás ejecución

I read the documentation on 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) {
    // ... demás ejecución

    // Stop listening to changes
    unsubscribe();
    
asked by Emiliano Pamont 29.10.2018 в 00:44
source

0 answers