1

The second observable of my resolver has to use the result of the first observable. I couldn't fiure out how to pass that data to the second observable :

  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)

        )
    );
  }

Thanks for your help!

RidRoid
  • 961
  • 3
  • 16
  • 39

1 Answers1

2

You'd need to use any of the RxJS higher order mapping operators in cases where an observable depends on the emission of another observable.

Illustration using switchMap operator

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))
  );
}  
ruth
  • 29,535
  • 4
  • 30
  • 57