mergeMap有一个方便的属性:concurrent: number,但我需要通过流输入上的一个属性来动态设置它。我想使用iif(),但无法添加mergeMap作为第二个或第三个参数,如下所示:
iif(
() => input.concurrentCallsLimit === 1,
mergeMap(of('foo'), 1),
mergeMap(of('foo'), 99)
)有没有人能给我举个例子,告诉我如何将mergeMap包含到iif中?我一直收到以下错误:
Uncaught TypeError: You provided 'function (source) {
return source.lift(new MergeMapOperator(project, concurrent));
}' where a stream was expected. You can provide an Observable, 发布于 2020-01-29 18:19:19
如果将input.concurrentCallsLimit转换为可观察对象(使用ex的主题),则可以执行以下操作:
concurrentCallsLimit$.pipe(
map(concurrentCallsLimit => (concurrentCallsLimit === 1 ? 1 : 99)),
distinctUntilChanged(),
switchMap(concurrentCallsLimit => mergeMap(of('foo'), concurrentCallsLimit))
);https://stackoverflow.com/questions/59957626
复制相似问题