title: Can someone explain that why the BehaviorSubject result like this?
body: <p>I wrote a service contain a BehaviorSubject called loginStatus and a function to return that.</p>
  <pre><code>private loginStatus = new BehaviorSubject&lt;boolean&gt;(false);
  
  getLoginStatus(): Observable&lt;boolean&gt; {
    return this.loginStatus;
  }
  </code></pre>
  <p>Then I subscribe it in other component's DOM with a async pipe in 4 different div, I just commented the shareReplay to show what I'm wondering.</p>
  <pre><code>  loginStatus$ = this.authService.getLoginStatus().pipe(
      switchMap(res =&gt; {
        if (!res) { return this.authService.isLoggedIn(); }
        else { return of(res); }
      }),
      tap(res =&gt; console.log('tap: ' + res)),
      //shareReplay(1),
   );
  </code></pre>
  <p>The isLoggedIn is a http request to check am I logged in or not, I check the loginStatus value in the switchMap, if it's false then call the isLoggedIn</p>
  <pre><code>isLoggedIn(): Observable&lt;boolean&gt; {
  console.log('called isLoggedIn');
  return this.httpService.get('/auth/isLoggined').pipe(
    map(res =&gt; {
      console.log('isLoggedIn res: ' + JSON.stringify(res));
      if (res) {
        this.loginStatus.next(true);
        this.firstName = res.first_name;
        this.lastName = res.last_name;
        this.tel = res.tel;
        return 'fool';
      } else {
        this.clearAll();
        return false;
      }
    }),
  </code></pre>
  <p>Finally It's my console result:</p>
  <pre><code>called isLoggedIn
  called isLoggedIn
  called isLoggedIn
  called isLoggedIn
  </code></pre>
  <p>isLoggedIn called 4 times because of my 4 async pipe, and the loginStatus is false.</p>
  <p>while the first http request response, I got a json object like {first_name:xxx, last_name:yyy, 1234}, so I push the true to the loginStatus and return a 'fool' to the further operator.</p>
  <p>I suppose that I will get the fool in the tap operator of the loginStatus$, but it doesn't.</p>
  <pre><code>isLogedIn res: {&quot;logined&quot;:true,&quot;first_name&quot;:&quot;xxx&quot;,&quot;last_name&quot;:&quot;yyy&quot;,&quot;tel&quot;:&quot;1234&quot;}
  tap: true
  tap: true
  tap: true
  tap: true
  </code></pre>
  <p>I only got the response of the first isLoggedIn request, the other 3 is lost.
  And I never get the fool, all the async pipe get the true from the loginStatus BehaviorSubject I guess.</p>
  <p>Then I commented the this.loginStatus.next(true) in the isLoggedIn function to compare the result.</p>
  <pre><code>isLogedIn res: {&quot;logined&quot;:true,&quot;first_name&quot;:&quot;xxx&quot;,&quot;last_name&quot;:&quot;yyy&quot;,&quot;tel&quot;:&quot;1234&quot;}
  tap: fool
  isLogedIn res: {&quot;logined&quot;:true,&quot;first_name&quot;:&quot;xxx&quot;,&quot;last_name&quot;:&quot;yyy&quot;,&quot;tel&quot;:&quot;1234&quot;}
  tap: fool
  isLogedIn res: {&quot;logined&quot;:true,&quot;first_name&quot;:&quot;xxx&quot;,&quot;last_name&quot;:&quot;yyy&quot;,&quot;tel&quot;:&quot;1234&quot;}
  tap: fool
  isLogedIn res: {&quot;logined&quot;:true,&quot;first_name&quot;:&quot;xxx&quot;,&quot;last_name&quot;:&quot;yyy&quot;,&quot;tel&quot;:&quot;1234&quot;}
  tap: fool
  </code></pre>
  <p>It's result with this which is what I prefered, I called 4 times, so I got 4 responses and It pass the fool to the tap 4 times.</p>
  <p>I wanna know why the other reponse is lost when I change the BehaviorSubject in the process of the first subscription.<br />
  And why all 4 subscription get the true value, I suppose at least the first time will get the fool.<br />
  Does it means the BehaviorSubject will cancel the further process when change rather than complete it?</p>