3

The new paging library can also work with Firebase real-time database or Cloud Firestore? I know that it works asynchronously but is there any way it can work with a real-time database?

Thanks!

Joan P.
  • 2,368
  • 6
  • 30
  • 63
  • I think you might be interested in this article, [How to paginate Firestore using Paging 3 on Android?](https://medium.com/firebase-tips-tricks/how-to-paginate-firestore-using-paging-3-on-android-c485acb0a2df). – Alex Mamo Jan 25 '21 at 18:34

1 Answers1

3

Regarding Firestore, you can use FirestorePagingAdapter:

The FirestorePagingAdapter binds a Query to a RecyclerView by loading documents in pages. This results in a time and memory efficient binding.

The FirestorePagingAdapter is built on top of the Android Paging Support Library.

Community
  • 1
  • 1
Peter Haddad
  • 78,874
  • 25
  • 140
  • 134
  • 2
    Thanks for your answer. If we are using `FirestorePagingAdapter` we lose the real-time feature, is it correct? – Joan P. Aug 08 '18 at 13:45
  • 2
    @IoanaP. Peter is right, you can paginate using `FirestorePagingAdapter` and you're also right guessing that you'll lose the real-time feature. Please see Frank's answer from this [post](https://stackoverflow.com/questions/50273741/firestorepagingadapter-not-receiving-realtime-updates) where he explains that `FirestorePagingAdapter` is designed to get data, not to listen for realtime updates. – Alex Mamo Aug 08 '18 at 15:38
  • 2
    @IoanaP. If you want to use the real-time feature you should use [FirestoreRecyclerAdapter](https://github.com/firebase/FirebaseUI-Android/tree/master/firestore#choosing-an-adapter), binds a Query to a RecyclerView and responds to all real-time events included items being added, removed, moved, or changed. Best used with small result sets since all results are loaded at once. If you have large result sets, you can load data in small chunks and for that I recommend you see my answer from this **[post](https://stackoverflow.com/questions/50741958/how-to-paginate-firestore-with-android)**. – Alex Mamo Aug 08 '18 at 15:40
  • Thanks Peter, thanks Alex! `FirestoreRecyclerAdapter` is what I was looking for. – Joan P. Aug 08 '18 at 15:49