可以将Firebase用作Room的远程数据源,以分页库作为单一的真实数据源吗?

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

can we use firebase as remote source with room as a single source of truth in paging library?

问题

我想在我的项目中使用分页库,其中我的远程数据源是Firebase Firestore,而我的本地数据源或唯一数据源是一个Room数据库,但当我搜索时,我没有找到任何关于如何将它们一起实现的教程或GitHub示例代码。

在使用分页库时,我遇到的一个问题是,当我将它们一起使用时,第一次加载项目,但当我滚动列表时,它没有再次调用加载函数以追加更多数据,但当我关闭应用程序并再次打开时,它会加载更多数据。

我尝试了很多方法来实现它,但没有成功,你有没有任何资源可以用来实现这些?有GitHub资源吗?

我找到了许多示例和资源,它们使用了Retrofit作为远程数据源,但没有使用Firebase。

英文:

I want to use the paging library in my project where my remote data source is Firebase Firestore and my local data source or single source of truth is a room database, but when I searched, I did not get any tutorial or GitHub sample code to implement these all together.

And one problem I am facing in paging Library is that when I am using these all together then the first time it loads the items, but when I scroll the list it did not call the load function again to append more data, but when I close the app and again open, then it loads more data.

I tried a lot to implement it, but did not get success, do you have any resources to implement these. any GitHub resource?

I found many examples and resources that use remote data sources using a retrofit, but not with Firebase.

答案1

得分: 1

Firestore已经有自己的持久化机制。对于Android和iOS,它默认启用。因此,无需创建额外的本地数据库,因为Firestore维护了数据库的本地副本。这对于离线使用是必要的。

在分页方面,我认为以下资源将有所帮助:

英文:

> I did not get any tutorial or GitHub sample code to implement these all together.

That's most likely because Firestore already has its own persistence mechanism. For Android and iOS, it is enabled by default. So there is no need to create an additional local database because Firestore maintains a local copy of the database. This is needed for offline usage.

When it comes to pagination, I think that the following resource will help:

huangapple
  • 本文由 发表于 2023年7月20日 17:29:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/76728489.html
匿名

发表评论

匿名网友

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

确定