Cerberos
Cerberos

Reputation: 101

Should I use ViewModel with UseCase?

This is more of a question about designing applications, rather than fixing a specific issue.

So most Android tutorials I see use ViewModel as a layer between the data source and the views. Hence my first impression was that a ViewModel is supposed to handle data fetching and updating, but then I read about 'Use cases' which most Android samples don't even mention and I don't understand how all these parts fit together. What's the relationship between a ViewModel and a use case?

Upvotes: 1

Views: 1226

Answers (1)

Pasha Shkaran
Pasha Shkaran

Reputation: 1481

1) Clean Architecture this is approach how to design your application. This is not about specific realization like in case of ViewModel.

2) If you looked at the official Android documentation you will not find any mentions of Clean Architecture. Google not forcing this approach.

3) ViewModel this is part of MVVM design pattern. So if we looking info Clean Architecture MMVM can be part of Presentation layer (same as MVP commonly used in this layer). But you still need UseCase to make interactions between Data layer and Presentation layer.

Upvotes: 0

Related Questions