Ram*_*a S 2 error-handling rxjs angular combinelatest
我需要在此CombineLatest中处理每个函数的错误情况。我将在下面添加代码
const combined = combineLatest(
this.myservice1.fn1(param),
this.myservice2.fn2(),
this.myservice3.fn3());
const subscribe = combined.subscribe(
([fn1,fn2, fn3]) => {
// operations i need to do
},
// how to handle error for fn1, fn2, fn3 separately
(error) => {
}
);
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激!
您可以在使用combineLatest最新源之前捕获每个可观察源的错误,如果您想稍后处理它们或将其转换为其他错误,则最终将其重新抛出:
combineLatest(
this.myservice1.fn1(param)
.pipe(
catchError(err => {
if (err.whatever === 42) {
// ... whatever
}
throw err;
}),
),
this.myservice2.fn2()
.pipe(
catchError(err => /* ... */),
),
...
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
736 次 |
| 最近记录: |