Android MutableLiveData.value = getNewValue() does not work
Why it's not possible to directly set the mutableLiveData.value when using a suspend function? See following code:
private val _clubs: MutableLiveData by lazy {
MutableLiveData().also {
fetchClubListFromRepository()
}
}
private fun fetchClubListFromRepository() {
viewModelScope.launch {
// This doen NOT work
_clubs.value = clubsRepository.getAllClubs()
// This works
var clubsList = clubsRepository.getAllClubs()...