Skip to content Skip to sidebar Skip to footer

Returning Value From Behaviorsubject In Angular 6 Guard

I'm going this direction because i've another guard who is validating the user on the token previously stored. This is what i was doing in previous version of rxjs, now in the late

Solution 1:

return your behaviorSubject as an observable in your authservice:

private _authed: BehaviorSubject<boolean> = newBehaviorSubject(null);

behaviorsubject():Observable<boolean> {
   returnthis._authed.asObservable()
}

Also a small comment: CanActivate works with observables, so if your behaviorsubject function returns a Observable with type boolean, you don't need to map it

Post a Comment for "Returning Value From Behaviorsubject In Angular 6 Guard"