有没有在Angular中有条件地调用mergeMap的RxJS方法:
return apiService.myApi.get().pipe(map(res => res), mergeMap(res => this.getPeople(res)))类似这样的东西:
return apiService.myApi.get().pipe(map(res => res),
someCond ? mergeMap(res => this.getPeople(res)) : null)发布于 2020-09-08 02:22:20
不能,但您可以使用of()返回原始值,或者使用EMPTY不再发出任何内容:
return apiService.myApi.get().pipe(
map(res => res),
mergeMap(res => someCond ? this.getPeople(res) : of(res)),
);https://stackoverflow.com/questions/63782509
复制相似问题