Can Cloud Firestore onSnapshot() only trigger on changes, and not get the initial state?

后端 未结 4 1560
故里飘歌
故里飘歌 2020-12-17 20:35

The documentation says:

You can listen to a document with the onSnapshot() method. An initial call using the callback you provide creates a document s

4条回答
  •  独厮守ぢ
    2020-12-17 21:12

    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.

提交回复
热议问题