我有一个可能返回的服务器呼叫
HTTP 202
. 受影响
this SO
线程,我有以下内容:
this.http.get(url)
.pipe(
map(response => {
if (response.status === 202) {
throw response;
}
return response;
}),
retryWhen(errors => {
return errors.pipe(
delay(1000),
take(3),
concat(response => Observable.throw('Retries exceeded'))
);
}),
catchError(handleError)
);
得到一个
deprecated
关于使用的警告
concat
. 我了解新的
康塔特
是在
rxjs
而不是
rxjs/operator
.
但是,什么是正确的使用新的
static concat
接线员在这里?
找到以下内容
from this site
import { concat } from 'rxjs/operators';
a$.pipe(concat(b$, c$));
// becomes
import { concat } from 'rxjs';
concat(a$, b$, c$);
我不能把脑袋包起来
Observable
在我的示例代码中连接了s?
更新1
将代码更改为:
return concat(this.http.get(url)
.pipe(
map(response => {
if (response.status === 202) {
throw response;
}
return response;
}),
retryWhen(errors => {
return errors.pipe(
delay(1000),
take(3)
);
}),
catchError(handleError)
), response => Observable.throw('Retries exceeded'));
但这会导致:
core.js:1598 ERROR TypeError: You provided 'function (response) { return rxjs__WEBPACK_IMPORTED_MODULE_2__["Observable"].throw('Retries exceeded'); }' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.
at subscribeTo (subscribeTo.js:41)
at subscribeToResult (subscribeToResult.js:6)
at