Convert LiveData to MutableLiveData

后端 未结 4 2049
天命终不由人
天命终不由人 2021-02-14 13:28

Apparently, Room is not able to handle MutableLiveData and we have to stick to LiveData as it returns the following error:

error: Not sure how to convert a Curso         


        
4条回答
  •  离开以前
    2021-02-14 13:34

    Since Room doesn't support MutableLiveData and has support for LiveData only, your approach of creating a wrapper is the best approach I can think of. It will be complicated for Google to support MutableLiveDatasince the setValue and postValue methods are public. Where as for LiveData they are protected which gives more control.

提交回复
热议问题