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"?

Philip Kendall
26k10 gold badges66 silver badges68 bronze badges
asked May 7, 2022 at 11:22

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)
answered May 9, 2022 at 10:57
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 :( Commented May 9, 2022 at 13:17

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.