I've implemented an Auth guard in one of the routes calling the authState method of AngularFireAuth.
I've seen plenty of example like the following to grant access:
return this.afAuth.authState.map(user => {
if(isNullOrUndefined(user)){
this.router.navigate(['auth/login']);
return false;
}else{
return true;
}
})
But when I try to replicate it as is, I receive the following error : '...Property 'map' doesn't exist on type 'Observable'.
But when I include .pipe it works as expected :
return this.afAuth.authState.pipe(map((user) => {
if(isNullOrUndefined(user)){
this.router.navigate(['auth/login']);
return false;
}else{
return true;
}
} ))
Maybe I should be satisfied it's working like this, but I can't understand why pipe is needed here. Anyone would have a few min to explain this to me ?
Many thanks ! Nanex