我的解析器的第二个可观测到的结果必须使用第一个可观测的结果。我无法解释如何将这些数据传递给第二个可观察到的人:
resolve(route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<[Project[], Owner]> {
const currentEmail = this.CurrentUserEmail();
return this.searchService.genericSearchApi('/api/searchproject', ...[//I need to pass the user here.]]).pipe(
withLatestFrom(
this.userService.getUserByEmail(currentEmail)
)
);
}
谢谢你的帮忙!
发布于 2020-10-28 05:01:08
在可观测到的依赖于另一个可观测到的发射量的情况下,您需要使用任何一个RxJS高阶mapping operators。
使用switchMap
算子的图解
resolve(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
): Observable<[Project[], Owner]> {
const currentEmail = this.CurrentUserEmail();
return this.userService.getUserByEmail(currentEmail).pipe(
switchMap(user => this.searchService.genericSearchApi('/api/searchproject', user))
);
}
https://stackoverflow.com/questions/64573294
复制