in the ViewModel I have MutableLiveData<MutableList<object>> and I want to create LiveData<List<object>>, but I don't know how to create List from MutableList.
Here is what I'm trying to do:
class AppViewModel : ViewModel() {
private val _tasks = MutableLiveData<MutableList<Task>>(mutableListOf())
val tasks: LiveData<List<Task>> = _tasks
}
(but I'm getting error Type mismatch. Required: LiveData<List> Found: MutableLiveData<MutableList>)
When I change the val tasks: LiveData<List<Task>> = _tasks to val tasks: LiveData<MutableList<Task>> = _tasks it works, but I want the List in tasks not to be editable.