美文网首页
rxjs使用flatmap switchmap接口请求失败,再次

rxjs使用flatmap switchmap接口请求失败,再次

作者: OnePiece索隆 | 来源:发表于2020-07-27 16:53 被阅读0次

catchError接受的lambda有一个平时都不怎么使用的第二个参数,caught,代表原Observable,只需要重新订阅原Observable即可

const list$ = new Subject();
list$.pipe(
  switchMap(() => {
      return http.get(url);
  }),
  catchError((err, caught) => caught)
 ).subscribe(res => {});

相关文章

网友评论

      本文标题:rxjs使用flatmap switchmap接口请求失败,再次

      本文链接:https://www.haomeiwen.com/subject/kvazlktx.html