Flow
有很多运算符,LiveData
只有3个(变换).除了StateFlow还处于实验阶段之外,还有什么理由继续使用LiveData吗?
UPD. StateFlow, SharedFlow and corresponding operators are promoted to stable API in kotlinx.coroutines 1.4.0
Flow
有很多运算符,LiveData
只有3个(变换).除了StateFlow还处于实验阶段之外,还有什么理由继续使用LiveData吗?
UPD. StateFlow, SharedFlow and corresponding operators are promoted to stable API in kotlinx.coroutines 1.4.0
现在没有太多理由使用LiveData.(状态)流/协同 routine 还通过lifecycleScope.launchWhenCreated/Started/Resumed,带来了实时数据难以实现的新可能性.
但是,当需要LiveData时,有一个原因-数据绑定.它目前不支持观察流.
EDIT: there is going to be support for StateFlow in DataBinding in Android Studio 4.3: https://twitter.com/manuelvicnt/status/1314621067831521282