Reputation: 4035
I'm building an Android app following the MVVM
architecture. Where do adapters (for recyclerView
, viewPager
, etc) belong to?
Do adapters
belong to View
or ViewModel
?
Upvotes: 33
Views: 13895
Reputation: 4087
If you're following MVVM architecture than , adapters are belongs to View
not Viewmodel
. All sub list item click events and other UI related things handled by adapter . So Adapter goes to View ..
if you want detail description , You can check this link to
Upvotes: 8
Reputation: 157
Think on this direction.. Suppose you remove/replace your view from your code. View model should be able to reused again and can provide view data to new view. You can get answer yourself. Then adapter should be part of view only.
Upvotes: 5
Reputation: 1448
Adapter belongs to View, but data source of Adapter belongs to ViewModel.
Upvotes: 44