【发布时间】: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) => {........)