安卓。如何将分页用于干净的体系结构?

发布于 2025-01-31 11:18:08 字数 373 浏览 3 评论 0原文

我正在使用MVVM和清洁体系结构编写应用程序。在其中一个屏幕上,我需要用pagination实现recyclerview。我将使用库paging3

Android开发人员建议在存储库中使用pagingsourceElletemeTemediator。但是与此同时,在许多来源中,我读到数据层和域层对Android框架一无所知。

但是现在我必须在数据层的数据源中使用Android库。在清洁体系结构的上下文中,这是否正确?

请帮助我弄清楚,我不明白如何使用干净的体系结构实施分页。

I'm writing application with MVVM and clean architecture. On one of the screens I need to implement RecyclerView with pagination. I am going to use the library Paging3.

Android Developer recommends using PagingSource and RemoteMediator in repository layer. But at the same time, in many sources, I read that the data layer and the domain layer should not know anything about the android framework.

But now I have to use the android library in the data sources of my data layer. Is this correct in the context of a clean architecture?

Please help me figure it out, I don't understand how to implement pagination using clean architecture.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初见 2025-02-07 11:18:08

分页库分为多个工件。有Paging-common,它是一个纯的Kotlin库,其中包含pagingsourceReletemeTemediator等。然后,有一个分页 - runtime,它是一个Android库,该库将使用recyclerviewPaging-compose,它是另一个Android库,它确实可以JetPack组成的UI也是如此。

这意味着您可以在纯Kotlin模块中使用Paging-common,在您的存储库中可以使用,其中没有Android特定代码。如果您自己编写该平台特定的接线,您甚至可以在不同平台上使用该存储库。

Paging library is split into multiple artifacts. There is paging-common, which is a pure kotlin library that contains PagingSource and RemoteMediator among others. Then, there is a paging-runtime which is an android library that wires paging sources with RecyclerView and paging-compose, another android library that does the same for Jetpack Compose UI.

That means that you can use paging-common in a pure kotlin module and in your repositories just fine, there is no android specific code in there. You can even use that repository on different platform, if you write that platform specific wiring yourself.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文