I\'ve noticed, when I try to use a realtime listener on a Collection in firestore, each time a new Document is added to the collection, the logic will be rerun, and I will d
It seems that the onSnapshot
is only for listening an entire document,which means it would return all of the fields in a document that you're listening. So you are not able to only retrieve the changed field.
But you can do different things according to different types of change:
xxxx.onSnapshot(function(querySnapshot){
querySnapshot.docChanges.forEach(function(change){
if(change.type=="added"){//first time it will be triggered
}else if(change.type == "modified"){//modified
}else if(change.type == "removed"){//removed
}
})
})
Hope this helps