2

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

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)
1
  • 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 :( May 9, 2022 at 13:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.