LiveData、MutableLiveData 的区别 [英] Difference between LiveData, MutableLiveData

查看:88
本文介绍了LiveData、MutableLiveData 的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 MutableLiveData 扩展了 LiveData,但它们之间有什么区别(在用法上).什么是合适的用例,意味着什么时候从两者中使用正确的一个?

I know that the MutableLiveData extends LiveData, but what is the difference between them (in usage). What are appropriate use cases, means when to use the correct one from the two?

推荐答案

LiveData 是不可变的,而 MutableLiveData 是可变的.MutableLiveData 扩展了 LiveData 并提供了诸如 setValue()postValue() 之类的方法.

LiveData is immutable while MutableLiveData is mutable. MutableLiveData extends LiveData and provides methods like setValue() and postValue().

这篇关于LiveData、MutableLiveData 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆