MutableLiveData: Cannot invoke setValue on a background thread from Coroutine

后端 未结 6 1440
说谎
说谎 2020-12-25 10:27

I\'m trying to trigger an update on LiveData from a coroutine:

object AddressList: MutableLiveData>()
fun getAddressesLiveData(): L         


        
6条回答
  •  被撕碎了的回忆
    2020-12-25 11:12

    Use liveData.postValue(value) instead of liveData.value = value. It is called asynchronous.

    From documentation:

    postValue - Posts a task to a main thread to set the given value.

提交回复
热议问题