MVVM-Kotlin-Android-Architecture icon indicating copy to clipboard operation
MVVM-Kotlin-Android-Architecture copied to clipboard

Refactor: separate repo for each model

Open AbdAllahAbdElFattah13 opened this issue 3 years ago • 1 comments

Usually, we have multiple repos in the app, each responsible for a model. So for example:

  • AuthRepo
  • UserRepo
  • RecipeRepo

Same can be done to the local/remote DS, or as well as the DAOs.

The main reason for this is simply better SRP.

Currently in the app, we have only one repo, I think this can refactored.

AbdAllahAbdElFattah13 avatar Jul 30 '22 16:07 AbdAllahAbdElFattah13

Now we have the data repo interface is as followes:

interface DataRepositorySource { suspend fun requestRecipes(): Flow<Resource<Recipes>> suspend fun doLogin(loginRequest: LoginRequest): Flow<Resource<LoginResponse>> suspend fun addToFavourite(id: String): Flow<Resource<Boolean>> suspend fun removeFromFavourite(id: String): Flow<Resource<Boolean>> suspend fun isFavourite(id: String): Flow<Resource<Boolean>> }

I think we can easily break down into 3 separate repos:

  • AuthRepo
  • RecipesRepo
  • UserActionsRepo

I'm still thinking about the last two, should we merge them into one or keep them separate, so if anyone with any ideas please let me know.

AbdAllahAbdElFattah13 avatar Aug 05 '22 05:08 AbdAllahAbdElFattah13