I have a list of items on 1 screen of a mobile app ( android/ios). All the items are in 1 document in Firestore. The user clicks one of the items and moves to the next screen with item detail. The user makes some changes on the screen and saves. Now the user needs to be presented with the original items list screen. Now should I again fetch all the items from Firestore since 1 item is changed? Users may change several items 1 by 1. In this way, for every item change, I need to fetch the document again and again.
Asked
Active
Viewed 50 times
-1
1 Answers
1
If all your items are stored in a single document, to see the changes that are made in real-time, then you should listen for real-time updates. In this way, you don't have to fetch the document again and again.
When using real-time listeners, don't also forget to detach them, once are not needed anymore.

Alex Mamo
- 130,605
- 17
- 163
- 193
-
I think changes coming due to listener are still counted as document read. So if user is changing item 1 by 1 then a lot of document read will be done. Is this normal? May be I am over thinking about document read. Can cache be used to minimize document read? – anand Dec 19 '21 at 16:56
-
Yes, it's normal. Each change will trigger the listener, so you'll be billed with one document read. You can minimize that, by reading the data only from the cache. I have also written an article, [How to drastically reduce the number of reads when no documents are changed in Firestore?](https://medium.com/firebase-tips-tricks/how-to-drastically-reduce-the-number-of-reads-when-no-documents-are-changed-in-firestore-8760e2f25e9e) regarding that topic. – Alex Mamo Dec 20 '21 at 09:08