views-widgets-samples
views-widgets-samples copied to clipboard
What is the best way to use liveData and viewModel in RecyclerView's ViewHolders.
I am wondering if there is a best way to use LiveData and ViewModel to update RecyclerView's ViewHolders. Because in a complex ViewHolder, it is much better to let the ViewModel controls the ViewHolder to update it's UI. Also , when the ViewHolder wants to change the source in ViewModel. It can get ViewModel and call the related change method in ViewModel. the ViewHolder only need to observe the liveData in ViewModel. But I do not know how to write these code in the best way.
Have you checked RecyclerView's codelabs ? It may help you to find a proper way to work with,