【问题标题】:Rxjs retryWhen not calling [angular 5]Rxjs retryWhen not call [angular 5]
【发布时间】:2018-06-18 17:11:07
【问题描述】:

我有一个问题要订阅 retryWhen 有角度的 HttpClient。

我使用角度5.2.11,rxjs 5.5.11

 this._httpClient.get('myUrl').retryWhen((errors) => {
  console.log('retryWhen', errors);
  return errors.scan((count, error) => {
    if (count >= retryOptions.retries) {
      throw error;
    }
    return count + 1;
  }, 0)
    .delay(retryOptions.delay)
    .takeWhile(count => count <= retryOptions.retries);
});

当我这样做时,console.log 或断点永远不会被调用。

我已经导入了这样的运算符。 import { retryWhen } from 'rxjs/operators/retryWhen'; 并且 import 'rxjs/add/operator/retryWhen';

但结果是一样的,当我在请求过程中出错时,他做了一个无限循环

谢谢

【问题讨论】:

  • 试试this._httpClient.get('myUrl').pipe(.retryWhen((errors) =&gt; {........)

标签: angular rxjs


【解决方案1】:

事实上,这是工作对不起!

没看到,同事更新代码,加个Http拦截器,总是返回错误..

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-21
    • 2017-03-01
    • 2020-02-26
    • 2019-05-20
    相关资源
    最近更新 更多