title: BehaviorSubject tells me next is undefined
body: <p>In my auth.service.ts file</p>
  <pre><code>import { HttpClient } from '@angular/common/http';
  import { Injectable } from '@angular/core';
  import { JwtHelperService } from &quot;@auth0/angular-jwt&quot;;
  import { BehaviorSubject, map, Observable } from 'rxjs';
  import { environment } from 'src/environments/environment';
  import { Role } from '../modal/Role.enum';
  import { User } from '../modal/User';
  
    constructor(private httpClient: HttpClient) {
      let localUser = localStorage.getItem('user');
      if (localUser) {
        this.userSubject = new BehaviorSubject&lt;User&gt;(JSON.parse(localUser));
        this.user = this.userSubject.asObservable();
      }
    }
  
  
    public get userValue(): User {
      return this.userSubject?.value;
    }
  
  
  Login(model: any) {
      return this.httpClient.post(this.url + 'Login', model)
        .pipe(
          map((response: any) =&gt; {
            const tokenInfo = response;
            if (tokenInfo &amp;&amp; tokenInfo?.data?.token) {
              localStorage.setItem('token', tokenInfo.data.token);
              this.decodedToken = this.JwtHelper.decodeToken(tokenInfo.data.token);
              this.isLogin.next(true);
              this.customerStatus().subscribe((it: any) =&gt; {
                let data = it.data;
                const role: Role = (&lt;any&gt;Role)[data.roleCode];
                let user: User = {
                  id: data.id,
                  firstName: data.firstName,
                  lastName: data.lastName,
                  email: data.email,
                  phoneNumber: data.phoneNumber,
                  networkID: data.networkID,
                  token: tokenInfo.data.token,
                  role: role
                }
                localStorage.setItem('user', JSON.stringify(user));
                setTimeout(() =&gt; {
                  console.log(&quot;User&quot;)
                  console.log(user)
                  this.userSubject.next(user); // is undefined here
                }, 1500);
              });
            }
            return response;
          })
        );
    }
  </code></pre>
  <p>In my Login method,
  this.userSubject.next(user) is undefined here</p>
  <p>If I inspect the value for user, it has a valid JSON data.</p>
  <p>Pressing Refresh on the browser causes the application to work as expected. But I dont want to tell people to press 'Refresh'</p>
  <p>I added the timeout because I thought the userSubject needed a little more time to catch up. It does not seem to be the case.</p>
  <p>I am using Angular 14</p>