Reputation: 193
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?
Upvotes: 6
Views: 6875
Reputation: 261
You can see my repository where I did everything using DataBinding! Visit https://github.com/xyarim/android-architecture
Upvotes: 0
Reputation: 2764
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.
Upvotes: 1