什么是 switchMap 等价于未展平的形式? [英] What is switchMap equivalent to in unflattened form?
本文介绍了什么是 switchMap 等价于未展平的形式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果 flatMap()
等价于 map().mergeAll()
,那么 switchMap()
等价于什么?
解决方案
switchMap()
操作符等价于使用 map().switch()
.>
由于 switch()
运算符仅适用于高阶 Observable,因此前面的 map()
必须返回一个 Observable.没有 switchAll()
运算符,因为 switch()
运算符已经与高阶 Observables 一起工作(就像所有 *all()
运算符一样).
If flatMap()
is equivalent to map().mergeAll()
,
then what is switchMap()
equivalent to ?
解决方案
The switchMap()
operator is equivalent to using map().switch()
.
Since the switch()
operator works only with higher-order Observables the preceding map()
has to return an Observable. There's no switchAll()
operator because the switch()
operator already works with higher-order Observables(just like all *all()
operators).
这篇关于什么是 switchMap 等价于未展平的形式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文