Seeking assistance with the following code snippet:
firebase.firestore()
.collection("chatrooms")
.doc(`${chatId}`)
.collection(`${chatId}`)
.orderBy("timestamp")
.limit(50).onSnapshot((snapshot) => {
//performing operations on snapshot.val()
})
I have implemented this listener in my firestore setup and it consistently fetches only the latest 50 documents. My query is: If I want to remove this listener, can I use the following approach?:
firebase.firestore().collection("chatrooms").doc(`${chatId}`).collection(`${chatId}`).off();
I am uncertain if solely invoking .off()
on the reference will suffice in this scenario. Usually it works, but due to my ordered and limited query, I wanted to confirm.