androidmvvmandroid-jetpack-composeandroid-mvvmandroid-paging

Where to place the ItemsPagingSource file in Android project MVVM?


I have an Android project where I use MVVM. This is the structure:

src
 \_ domain
     \_ model
     \_ repository
          \_ ItemsRepository
 \_ data
     \_ repository
          \_ ItemsRepositoryImpl
 \_ presentations
     \_ items
          \_ ItemsScreen
          \_ ItemsViewModel

Today I have implemented pagination and I have created a ItemsPagingSource class. Where in this structure should I place such a file to not break MVVM rules?


Solution

  • Where in this structure should I place such a file to not break MVVM rules?

    PagingSource is a source of data - hence it would go with your data layer.

    Maybe src/data/repository. Or src/data/paging if you want to get granular.

    That said, there are no "MVVM rules" for you to break as far as organizing your code. That's up to your personal (or team) preference to organize things in the way that's most logical for you.