现在不推荐使用mergeMap
,并且源中包含此注释:
/* @deprecated resultSelector no longer supported, use inner map instead */
如何使用"内部地图"代替?我想这意味着在map
内使用.pipe
运算符函数,但是observable不会像mergeMap
一样展平。
obs1$.pipe(map(() => obs2$)).subscribe(r => console.log(r === obs2$))
// > true
那么,没有它的mergeMap
相当于怎样?
答案 0 :(得分:5)
你仍然使用mergeMap,它只是弃用的resultSelector函数。
这个不被弃用:
export function mergeMap<T, R>(project: (value: T, index: number) => ObservableInput<R>, concurrent?: number): OperatorFunction<T, R>;
但是,这些是:
/** @deprecated resultSelector no longer supported, use inner map instead */
export function mergeMap<T, R>(project: (value: T, index: number) => ObservableInput<R>, resultSelector: undefined, concurrent?: number): OperatorFunction<T, R>;
/** @deprecated resultSelector no longer supported, use inner map instead */
export function mergeMap<T, I, R>(project: (value: T, index: number) => ObservableInput<I>, resultSelector: (outerValue: T, innerValue: I, outerIndex: number, innerIndex: number) => R, concurrent?: number): OperatorFunction<T, R>;