I'm using a ListAdapter for my recyclerView and because I'm working with a mutableList in my viewModel, my recyclerView UI does not update the list if I just pass the same mutableList updated. The simple solution is to type 'it.toList()', but I worry this takes too long creating an completely new list. Is there a better way? Also, explaining how '.toList()' works might help me understand this.
from:
viewModel.basicItems.observe(viewLifecycleOwner) {
recyclerAdapter.submitList(it)
}
to:
viewModel.basicItems.observe(viewLifecycleOwner) {
recyclerAdapter.submitList(it.toList())
}