Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android MVVM + DataBinding RecyclerView

i'm trying to implement MVVM architecture + DataBinding + RxJava. i have an activity with RecyclerView. as i understand the ViewModel should not have a reference to the View. what's the correct way in MVVM to pass the data list from the ViewModel to the RecyclerView in the activity? pass the data via interface like in MVP?

like image 687
stav elmashally Avatar asked Jan 14 '18 12:01

stav elmashally


1 Answers

You should add data binding to your ViewHolder. You can read some articles like this to make it more clear.

By the way I faced problem when using MVVM + Databinding Library when trying to apply animations or for example trying to implement postdelayed. Of course you can create tons of custom binding adapters, but it a lot easier to use view directly, so sometimes you have to use MVP like connections between ViewModel and View.

like image 139
Anton Kazakov Avatar answered Sep 22 '22 14:09

Anton Kazakov