I'm trying to clarify the semantics of Firestore query snapshot updates in the face of changing documents. The "Listen to multiple documents in a collection" doc says:
The snapshot handler will receive a new query snapshot every time the query results change (that is, when a document is added, removed, or modified).
My question is if a document that was already in the snapshot is updated, will it always trigger a new query snapshot? Even if the change to the document has nothing to do with the original query? Is this documented somewhere? (Specifically, what is the definition of "query results change"?)
Consider a case with several existing documents in a collection. Start by querying for all the documents, for example:
db.collection("cities").onSnapshot(snapshot => { ... })
Now if a new document is created in the collection, or a document is removed, the onSnapshot callback will be re-invoked with those changes because the "query results" are different.
But what happens if a document in that example collection is modified after the initial onSnapshot callback is invoked? (E.g., a new property is added to one of the "cities" documents.) Will the onSnapshot callback always be invoked to report this modified document? Does this count as changing the "query results"? The set of documents returned is not different, so it seems like this sort of change might not be reported in the collection query?
In truth I'm seeing some odd behavior in my application, and I'm trying to double-check what the semantics of onSnapshot collection updates are intended to be. In comparison, the documentation for single-document onSnapshot semantics is clearer about reporting all content changes:
An initial call using the callback you provide creates a document snapshot immediately with the current contents of the single document. Then, each time the contents change, another call updates the document snapshot.
But I cannot find similar clarity for the collection snapshot documentation.