在StateFlow / SharedFlow中,这个实时数据转换的等效代码是什么?
val myLiveData: LiveData<MyLiveData> = Transformations
.switchMap(_query) {
if (it == null) {
AbsentLiveData.create()
} else {
repository.load()
}
基本上,我想监听每个查询更改,以便根据情况返回内容。 因此,任何使用StateFlow / SharedFlow类似的东西都可以。