title: My variable keeps returning to default boolean value and my subscription won't proc from an observable
body: <p>I am a beginner in Angular/Node.js and I am doing a project as a practice.
  I got stuck in an authentication problem using subscriptions and observables.</p>
  <p>While my authentication works, I am trying to visually hide my login/signup buttons on successful authentication, and show a logout button instead.</p>
  <p>I am using the '*ngIf=&quot;userIsAuthenticated&quot;' to show my logout and '*ngIf=&quot;!userIsAuthenticated&quot;' to hide signup/login buttons.</p>
  <p>In my authService class file I have this:</p>
  <pre><code>private authStatusListener = new Subject&lt;boolean&gt;();
  
  constructor(private http: HttpClient, private router: Router) {}
  
  getAuthStatusListener() {
  return this.authStatusListener.asObservable();}
  
  login(email: string, nickname: null, password: string ) {
  const authData: AuthData = {
    email: email,
    nickname: nickname,
    password: password,
  };
  this.http
    .post&lt;{token: string}&gt;(BACKEND_URL + '/login', authData)
    .subscribe((response) =&gt; {
      const token = response.token;
      this.token = token;
      this.authStatusListener.next(true);
      this.router.navigate([&quot;/&quot;]);
    });}
  </code></pre>
  <p>In my component .ts file i have this:</p>
  <pre><code>private authListenerSubs: Subscription;
  userIsAuthenticated = false;
  
  constructor(
  private authService: AuthService,
  public reviewService: ReviewService)
  
  ngOnInit() {
  
  this.authListenerSubs = this.authService
    .getAuthStatusListener()
    .subscribe((isAuthenticated) =&gt; {
      console.log('testing if this runs');
      console.log(this.userIsAuthenticated);
      this.userIsAuthenticated = isAuthenticated;
      console.log(this.userIsAuthenticated);
    });
  console.log(this.userIsAuthenticated);
  this.authListenerSubs = this.authService
    .getAuthStatusListener()
    .subscribe();}
  </code></pre>
  <p>I put a bunch of console.logs to see how my variable behaves. Also you probably notice the seemingly useless code <code>this.authListenerSubs = this.authService .getAuthStatusListener() .subscribe();</code>
  but none of my logs inside the subscribe method won't execute for some reason if this piece of code isn't below that code, and I have no idea why that is the case or how these things are related.</p>
  <p>The main problem is that this.userIsAuthenticated won't be updated.
  My logs say that the value starts at false as it should be, then gets changed to true as it should be, but when it finishes the subscribe, it then immediately returns to false value, even though it shouldn't as it was changed and nowhere do I change it back to false.</p>
  <p>Can anyone please help me?</p>