KunMinX / UnPeek-LiveData

LiveData 数据倒灌:别问,问就是不可预期 - Perfect alternative to SingleLiveEvent, supporting multiple observers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

还是会发生数据倒灌

zhaoxiuyu opened this issue · comments

image

VoicePtaView 是自定义 ConstraintLayout,里面包含多个Fragment。
当VoicePtaView 多次被 removeVIew 并 addVIew时, 就会发生数据倒灌,收到多次回调。

Fragment中
val viewModel by activityViewModels()

初始化
val mTTSLiveData: MutableResult<BaseResponse<List>> =
MutableResult.Builder<BaseResponse<List>>().setAllowNullValue(true).create()

/// 订阅
viewModel.mTTSCloneListDataLiveData.observe(viewLifecycleOwner){}

根据你提供的信息,暂无法判断具体造成旧数据回推的原因。可以试试 MVI-Dispatcher 组件来做消息分发。

https://github.com/KunMinX/MVI-Dispatcher-KTX

另外,我在调用.clean()方法时报错了
image