The documentation says:
You can listen to a document with the onSnapshot() method. 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.
I just want my listener to fire when the data changes. I don't want it to fire when the app loads, to get the initial state of the data. Any suggestions?
Firestore listeners loads by their own order and the "onSnapshot" event must always execute first on initial state. But, you can handle that behavior adding a initial state variable like:
Then you could validate inside the function the code you dont want to run when your application starts.
and after the application starts up you must change initState to false and add a sleep/timeout function (cause it may have an unexpcted asyncronous load)
Firestore listeners don't work that way. You will always be delivered the document(s) relevant to the fetch or query, then updates after that for as long as the listener remains added. There is no mode to receive deltas only.
If you want to receive only certain data, you might want to figure out how to query for it, for example, by adding a timestamp field and having the client only query for documents that have changed since some prior time.