英文:
What does .setInitialLoadSizeHint , .setPageSize and . setPrefetchDistance mean in firestorepagination?
问题
我想先加载10个文档,然后再加载10个,依此类推。这样正确吗?
Firestore分页是一次性加载所有数据吗?还是会从Firestore限制数据加载?
PagedList.Config config = new PagedList.Config.Builder()
.setEnablePlaceholders(false)
.setPrefetchDistance(2)
.setInitialLoadSizeHint(10)
.setPageSize(10)
.build();
英文:
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
得分: 1
Firestore分页加载是否一次加载所有数据?
不,它总是会加载您传递给 setPageSize()
方法的确切数量的元素。根据关于 PagedList.Config.Builder 的官方文档中的 setPageSize(int pageSize):
定义一次从DataSource加载的项目数量。
这里是关于 setInitialLoadSizeHint(int initialLoadSizeHint) 的信息:
定义在首次加载时要加载多少项目。
这里是关于 setPrefetchDistance(int prefetchDistance) 的信息:
定义从加载内容的边缘多远的访问需要触发进一步加载。
并且回答您的问题:
或者它会限制来自Firestore的数据吗?
是的,在您的情况下,它会将数据限制为每页10个元素。
英文:
> 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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论