5

在我拥有这个运行良好的解析器之前:

resolve() {
    return forkJoin(
        this.getData1(),
        this.getData2(),
        this.getData3()
    );
}

现在我必须做一些实际上不起作用的事情:

  resolve() {
    return this.actions$
      .pipe(
        ofActionSuccessful(SomeSctonSuccess),
        forkJoin(
           this.getData1(),
           this.getData2(),
           this.getData3()
        )
      );
    }

当我遇到这个错误时:

'Observable<[any, any, any, any]>' 类型的参数不能分配给'OperatorFunction' 类型的参数。类型 'Observable<[any, any, any, any]>' 与签名 '(source: Observable): Observable' 不匹配。

任何想法如何解决?

现在我注意返回我forkJoin唯一ofActionSuccessful(SomeSctonSuccess)的事情发生后https://ngxs.gitbook.io/ngxs/advanced/action-handlers

4

2 回答 2

3

使用exhaustMap运算符。它映射到内部可观察对象,忽略其他值,直到该可观察对象完成

import { forkJoin } from 'rxjs';
import { exhaustMap } from 'rxjs/operators';

resolve() {
    return this.actions$
      .pipe(
        ofActionSuccessful(SomeSctonSuccess),
        exhaustMap(() => {
         return forkJoin(
             this.getData1(),
             this.getData2(),
             this.getData3()
           )
       })

      );
    }
于 2018-05-29T03:22:04.833 回答
2

感谢@Sajeetharan,通过查看此网址最终使用exhaustMap

  resolve() {
    return this.actions$.pipe(
      ofActionSuccessful(LoadOnPremHostSuccess),
      exhaustMap(() => {
        return forkJoin(
          this.getData1(),
           this.getData2(),
           this.getData3()
        );
      })
    );

}

于 2018-05-29T03:22:33.057 回答