在我有这个工作正常的解析器之前:
resolve() {
return forkJoin(
this.getData1(),
this.getData2(),
this.getData3()
);
}
现在我必须做一些实际上不起作用的事情:
resolve() {
return this.actions$
.pipe(
ofActionSuccessful(SomeSctonSuccess),
forkJoin(
this.getData1(),
this.getData2(),
this.getData3()
)
);
}
因为我遇到此错误:
类型为"可观察<[任何、任何、任何、任何]>"的参数不可分配 到类型为"运算符函数"的参数。 类型 "可观察<[任何、任何、任何、任何]>"与签名不匹配 "(来源:可观察(:可观察"。
有什么想法如何解决吗?
现在我只注意在ofActionSuccessful(SomeSctonSuccess)
发生后才归还我的forkJoin
https://ngxs.gitbook.io/ngxs/advanced/action-handlers
使用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()
)
})
);
}
感谢@Sajeetharan通过查看此网址最终使用了exhaustMap
resolve() {
return this.actions$.pipe(
ofActionSuccessful(LoadOnPremHostSuccess),
exhaustMap(() => {
return forkJoin(
this.getData1(),
this.getData2(),
this.getData3()
);
})
);
}