当我下定决定形成并等待价值变化时,如果我的共鸣是我的服务错误......
这是代码:
[[3,3],[4,3],[2,1]]
修改
我发现了什么问题,它在http intreceptor里面:
constructor(private fb: FormBuilder, private bankService: BankService) {
this.page = 1;
this.filter = this.fb.group({
text: ['', []],
bankC: ['', []]
});
this.filter.valueChanges
// wait for a pause in typing of 200ms then emit the last value
.debounceTime(200)
// only accept values that don't repeat themselves
.distinctUntilChanged()
// map that to an observable HTTP request, using the TickerLoad
// service and switch to that
// observable. That means unsubscribing from any previous HTTP request
// (cancelling it), and subscribing to the newly returned on here.
.switchMap((val: any) => {
return bankService.getCountry(val.bankC)
})
.subscribe((res) => {
console.log(res);
},
(err) => {
console.log(err);
});
// send an empty array to tickers whenever clear emits by
// merging in a the stream of clear events mapped to an
// empty array.
}
正是这部分:intercept(observable: Observable<Response>): Observable<Response> {
return observable.catch((err, source) => {
if (err.status == 401) {
this._router.navigate(['']);
return Observable.throw(err);
//&& !_.endsWith(err.url, 'api/auth/login')
} else {
return Observable.throw(err);
}
});
}
如何在不制动订阅的情况下返回错误。
答案 0 :(得分:2)
如果您想在subscribe()
之前使用retry()
operator重新订阅来源Observable:
...
.switchMap((val: any) => {
return bankService.getCountry(val.bankC)
})
.retry(-1) // resubscribe forever
.subscribe((res) => {
console.log(res);
}, ...