Search code examples
androidandroid-viewmodelandroid-mvvm

Using Multiple Repsitory In ViewModel Is Bad Practice?


class HomeViewModel(
      private val employeeRepository: EmployeeRepository,
      private val localBodiesRepository: LocalBodiesRepository
) : ViewModel() {

}

I want to use both data's in my home activity it is a good practice or not if it is bad then what is the best practice?


Solution

  • Having multiple repositories is not a bad practice. It is even a good practice if repositories contains non related stuff. Yours example looks like repositories have disjoint data so it is cool to have it separated.