What does .setInitialLoadSizeHint , .setPageSize and . setPrefetchDistance mean in firestorepagination?

Viewed 242

I want to load 10 documents first and then 10 and so on. Is this correct?

And does Firestore pagination load all data at once? Or does it limit data from Firestore?

PagedList.Config config = new PagedList.Config.Builder()
              .setEnablePlaceholders(false)
              .setPrefetchDistance(2)
              .setInitialLoadSizeHint(10)
              .setPageSize(10)
             .build();
1 Answers

And does Firestore pagination load all data at once?

No, it will always load the exact number of elements that you pass to the setPageSize() method. According to the official documentation regarding PagedList.Config.Builder's setPageSize(int pageSize):

Defines the number of items loaded at once from the DataSource.

Here is the info for setInitialLoadSizeHint(int initialLoadSizeHint):

Defines how many items to load when first load occurs.

And here is the info for setPrefetchDistance(int prefetchDistance):

Defines how far from the edge of loaded content an access must be to trigger further loading.

And to answer your question:

Or does it limit data from Firestore?

Yes, it will limit the data, in your case, it will be limited at 10 elements per page.

Related