This blog on "Clean Architecture" describes how to build a modular Android application along with using Clean Architecture.
In that example project, the author places the business logic in a separate 'core' module and that module is framework independent. It contains repository classes, use-case classes, and data-source interfaces. All the other framework dependent components go in the 'app' module.
Android Paging library treats its PagingSource
class as a repo level component. Even RoomDao
classes have ability to directly return an instance of PagingSource
. In this case, we used to return Flow<PagingData>
from the repo methods. But now, we can't have PagingData
in repo class.
So, how to integrate AndroidX "Paging-3" in an app built inline with "Clean Architecture"?
1 Answer 1
Androidx-paging is a usefull tool that is not compatible with the blog-article proposed architecture:
- Article: usecases are (or should be) platform independent.
- Androidx-paging is platform dependent.
Paging is used by the presentation layer when (parts of) lists are displayed.
Affected layers:
- View Layer: (i.e. a RecyclingView to show the page)
- Usecase Layer: (i.e. show page 1 of 15) android-specific Androidx-paging
- Domain-Layer does not use entities but pagingdata
- Repository-Interface: (i.e. get item 1 - 15 of 220 items)
-
Ohh.. But the architecture mentioned blog post really looks very neat. I think 'Kotlin multiplatform mobile' also uses similar architecture. So
androidx-paging3
in incompatible with that too :(Sourav Kannantha B– Sourav Kannantha B2022年05月09日 13:17:15 +00:00Commented May 9, 2022 at 13:17
Explore related questions
See similar questions with these tags.