I am using a default client side auth service from a visual studio template.
There is a typescript AuthorizeService which has a function called isAuthenticated which calls the below function and checks that it is null or not.
The getUser function:
public getUser(): Observable<IUser> {
return concat(
this.userSubject.pipe(take(1), filter(u => !!u)),
this.getUserFromStorage().pipe(filter(u => !!u), tap(u => this.userSubject.next(u))),
this.userSubject.asObservable());
}
when .subscribe is called on the above function. Subscribe is called three times. Presumably for each observable in the concat function. Using getUser above, I would expect subscribe to be called once. How would I achieve that?
I tried converting the above to nested promises that returns one value but with no success as for some reason, after the result is returned, it returns resolve(null) even though the user exists in session storage