views-widgets-samples icon indicating copy to clipboard operation
views-widgets-samples copied to clipboard

What is the best way to use liveData and viewModel in RecyclerView's ViewHolders.

Open AlexMa1755 opened this issue 4 years ago • 1 comments

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.

AlexMa1755 avatar Oct 14 '20 08:10 AlexMa1755

Have you checked RecyclerView's codelabs ? It may help you to find a proper way to work with,

Yan9080 avatar Oct 18 '20 04:10 Yan9080