在Rxjs 6中将concat与管道一起使用的正确方法是什么?

kma*_*oor 5 rxjs angular angular-httpclient rxjs6

我有一个服务器呼叫可能返回HTTP 202受此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)
  );
Run Code Online (Sandbox Code Playgroud)

收到deprecated有关使用的警告concat。我知道新消息concat已经出现,rxjs而没有rxjs/operator

但是,static concat在这里使用new 运算符的正确方法是什么?

从该站点发现以下内容

import { concat } from 'rxjs/operators';
a$.pipe(concat(b$, c$));

// becomes

import { concat } from 'rxjs';
concat(a$, b$, c$);
Run Code Online (Sandbox Code Playgroud)

我无法确定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'));
Run Code Online (Sandbox Code Playgroud)

但这导致:

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 
Run Code Online (Sandbox Code Playgroud)

car*_*ant 10

可管道操作符只是接受一个 observable 并返回一个 observable 的函数。所以你可以concat像这样使用工厂函数:

retryWhen(errors => {
  return errors.pipe(
    delay(1000),
    take(3),
    o => concat(o, throwError('Retries exceeded'))
  );
})
Run Code Online (Sandbox Code Playgroud)

此外,concat操作员将被替换/重命名为concatWith. 看到这个问题