I have chosen this approach because I have another guard responsible for validating the user based on a token that was previously stored. This is how it was handled in previous versions of rxjs, but now with the latest version you can no longer use map on the subject.
canActivate(next: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {
return this.authservice.behaviorsubject().map(x => {
if (x) {
return true;
} else {
return false;
}
})
}
I need guidance on how to make this work. I attempted something like this, but it does not return anything since it was never subscribed to (and also it's not an Observable, it's an AnonymousSubject when logged into console).
canActivate(next: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {
return this.authservice.behaviorsubject().pipe(
map(x => {
if (x) {
return true;
} else {
return false;
}
})
)
}
I also tried converting it into an observable using Observable.create(), but it didn't work. I know I'm missing something. Help please :)