Issue
I need to combine UserRole from RealtimeDatabase and User from FirebaseAuth. How do I combine these two queries, one of which is based on the other? The following code allows you to download a single file or two files simultaneously.
from(this.auth.signInWithEmailAndPassword(email, password))
.pipe(
switchMap((result: any) => this.getUserRole(result.user.uid)),
take(1)
)
.subscribe(console.warn);
or
combineLatest([x1, this.getUserRole('8OKFSRBeZ3dY4ecQVn8AyJHBQim2')])
.pipe(tap(console.warn))
.subscribe();
Solution
Does it work for you? Note: combineLatest may be not the best for the case, you can try frokJoin.
from(this.auth.signInWithEmailAndPassword(email, password))
.pipe(
switchMap((result: any) => combineLatest(of(result.user), this.getUserRole(result.user.uid))),
)
.subscribe(console.warn);
Answered By - Leon
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.