在我拥有这个运行良好的解析器之前:
resolve() {
return forkJoin(
this.getData1(),
this.getData2(),
this.getData3()
);
}
Run Code Online (Sandbox Code Playgroud)
现在我必须做一些实际上不起作用的事情:
resolve() {
return this.actions$
.pipe(
ofActionSuccessful(SomeSctonSuccess),
forkJoin(
this.getData1(),
this.getData2(),
this.getData3()
)
);
}
Run Code Online (Sandbox Code Playgroud)
因为我遇到了这个错误:
“Observable<[any, any, any, any]>”类型的参数不可分配给“OperatorFunction”类型的参数。类型 'Observable<[any, any, any, any]>' 不匹配签名 '(source: Observable): Observable'。
任何想法如何解决?
现在我注意在发生forkJoin后返回我的唯一https://ngxs.gitbook.io/ngxs/advanced/action-handlersofActionSuccessful(SomeSctonSuccess)
使用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()
)
})
);
}
Run Code Online (Sandbox Code Playgroud)