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
When you use onSnapshot() on a collection, you're not actually downloading the entire collection on each invocation. The documents are cached and will be reused when the collection changes again.
For each change that causes your callback to be invoked, you can find out which documents are new seen since the first invocation by checking the changes within the snapshot. An example of how to do this is in the documentation. With a query snapshot in hand, you can use this logic to determine which documents are new:
snapshot.docChanges.forEach(function(change) {
if (change.type === "added") {
// change.doc here is new a new document
}
});