首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >用withLatest实现具有相关观测值的角分辨器

用withLatest实现具有相关观测值的角分辨器
EN

Stack Overflow用户
提问于 2020-10-28 12:54:13
回答 1查看 104关注 0票数 1

我的解析器的第二个可观测到的结果必须使用第一个可观测的结果。我无法解释如何将这些数据传递给第二个可观察到的人:

代码语言:javascript
代码运行次数:0
运行
复制
  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)

        )
    );
  }

谢谢你的帮忙!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-10-28 13:01:08

在可观测到的依赖于另一个可观测到的发射量的情况下,您需要使用任何一个RxJS高阶mapping operators

使用switchMap算子的图解

代码语言:javascript
代码运行次数:0
运行
复制
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))
  );
}  
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64573294

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档