Angular:如何使用RXJS 6调用finally() [英] Angular : how to call finally() with RXJS 6

查看:391
本文介绍了Angular:如何使用RXJS 6调用finally()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用RXJS 5,现在将其升级到6时,我遇到了一些问题.

I was using RXJS 5, now as I upgraded it to 6, I am facing some problems.

以前我能够使用catch并最终使用,但是由于每次更新catch都被catchError替换(管道中的with),现在如何最终使用?

Previously I was able to use catch and finally but as per update catch is replaced with catchError (with in the pipe) now how to use finally?

我还有一些问题:

我是否需要更改throw-> throwError(在下面的代码Observable.throw(err);中)

Do I need to change throw->throwError (in below code Observable.throw(err);)

import { Observable, Subject, EMPTY, throwError } from "rxjs";
import { catchError } from 'rxjs/operators';

return next.handle(clonedreq).pipe(
          catchError((err: HttpErrorResponse) => {
        if ((err.status == 400) || (err.status == 401)) {
            this.interceptorRedirectService.getInterceptedSource().next(err.status);
            return Observable.empty();
        } else {
            return Observable.throw(err);
        }
       }) 
        //, finally(() => {
        //  this.globalEventsManager.showLoader.emit(false);
        //});
      );

还有现在如何使用publish().refCount()吗?

Also how to use publish().refCount() now ?

推荐答案

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆