How do I subscribe a global variable to a BehaviorSubject?
How do I subscribe a global variable to a BehaviorSubject? I'm building a login function and I want certain buttons in the app.component template to appear the moment the user has logged in. I am trying to use BehaviorSubject for this. I'm using an *ngIf for the buttons in the template and the condition is a variable called loggedIn . However when I try to initialize the loggedIn variable with the result of the SubjectBehavior subscription i get the error: *ngIf loggedIn ERROR in app.component.ts(10,3): error TS2322: Type 'Observable<boolean>' is not assignable to type 'boolean'. I don't know whats causing this because I am returning a boolean, not an observable. Here is the code of app.component: export class AppComponent { private loggedIn: boolean = this.loginService.isLoggedIn().pipe( map((isLoggedIn: boolean) => { // {3} if (!isLoggedIn){ return false; } return true; })); constructor(private loginS...