这是我的代码:
this._api.getCompanies().subscribe(
res => this.companies = JSON.parse(res),
exception => {if(this._api.responseErrorProcess(exception)) { // in case this retured TRUE then I need to retry() } }
)
如果发生异常,它将被发送到 API 中的函数然后返回true
如果问题已解决(例如令牌刷新),并且只需要在解决后重试
我不知道如何重试。
In your .getCompanies()
之后立即致电.map
add a .retryWhen https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/operators/retrywhen.md:
.retryWhen((errors) => {
return errors.scan((errorCount, err) => errorCount + 1, 0)
.takeWhile((errorCount) => errorCount < 2);
});
在此示例中,可观察对象在 2 次失败后完成(errorCount < 2
).
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)