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

huangapple go评论115阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2020年8月17日 21:26:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/63451796.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定