Reputation: 39384
I have the following observables:
this.authenticationService.isSignedIn() -> Observable<Boolean>
this.user$ -> Observable<UserModel>
I need to check a condition based on both so I tried:
zip(this.authenticationService.isSignedIn(), this.user$).pipe(
map(([isSignedIn, user]: [boolean, UserModel]) => isSignedIn && user.claims))
);
Because I am getting an unexpected result I tried to check things out using:
zip(this.authenticationService.isSignedIn(), this.user$).pipe(
tap(([isSignedIn, user]: [boolean, UserModel]) => {
console.log(isSignedIn);
console.log(user);
})
);
But the two console.log
are not executed. What am I missing?
Upvotes: 2
Views: 2655
Reputation: 12036
you could be missing a subscribtion. All rxjs things are lazy and won't be running untill a subscription is done. if you don't need to handle the result somehow else except for your tap
operator, just add .subscribe()
in the end
zip(...).pipe(
tap(...)
).subscribe();
Upvotes: 5