Issue
These are the collections of my Android app:
- Faculty
- AnnualDue
- MedicalAid
- DeathAid
- MemberFee
- Announcement
In a single activity/fragment, I want to display:
- Total Faculty Members
- Total Annual Dues
- Total Medical Aid
- Total Death Aid
- Total Member Fees
- Total Announcement
I tried using multiple snapshot listeners loading at once in a single activity. It works fine but I'm worried if I am not following the best practices that it will cost me a lot. If you have another/better way to display the same result that I want, please give me an idea because I'm stuck in this part.
Solution
I tried using multiple snapshot listeners loading at once in a single activity. It works fine but I'm worried if I am not following the best practices that it will cost me a lot.
That's nothing wrong with using multiple snapshot listeners, as long as you keep the number of snapshot listeners per client under 100. What you should take into consideration, is the number of documents that are returned by your queries. Why? Because everything in Firestore is about the number you read operations you perform. If you have a lot of documents, then most likely you should use a limitation by calling Query#limit(long limit), or by implementing pagination.
If you understand Kotlin, the following resources will definitely help:
- How to paginate Firestore using Paging 3 on Android?
- How to implement pagination in Firestore using Jetpack Compose?
Answered By - Alex Mamo
Answer Checked By - Terry (JavaFixing Volunteer)