我想用b的响应作为参数进行c调用。如何实现呢?
resolve(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
): Observable<any> {
let a = this.loginService.getApplicationCentre();
let b = this.loginService.getLoginId();
let c = this.loginService.getUserDetails(response of (b))
let join = forkJoin(a, b, c).pipe(map((allResponses) => {
return {
A: allResponses[0],
B: allResponses[1],
C: allResponses[2]
};
}));
return join;
}
任何帮助将不胜感激!
答案 0 :(得分:2)
这可以如下进行:
let a$ = this.loginService.getApplicationCentre();
let bc$ = this.loginService.getLoginId()
.pipe(
mergeMap(b => this.loginService.getUserDetails(b)
.pipe(map(c => [b, c])))
);
return forkJoin(a$, bc$).pipe(map(([A, [B, C]]) => ({ A, B, C })));