title: Angular: switchMap UnsubscriptionError
body: <p>I have a type-ahead functionality implmented using the below code.</p>
  
  <pre><code>accounts = new Subject&lt;string&gt;();
  
  search(account) {
      this.accounts.next(account);
  }
  
  this.accounts
        .debounceTime(300)
        .distinctUntilChanged()
        .switchMap(account =&gt; account
          ? this.tpiService.searchAccount(account)
          : Observable.of&lt;any&gt;([]))
        .subscribe(response =&gt; this.matchedAccounts = response);
  </code></pre>
  
  <p>If I type in the textbox when there's an ongoing request, it's getting cancelled, but a new request is not sent then. On the next keystroke only a new request is sent. I've attached the trace of my console when this happens. I can't get what's happening. </p>
  
  <p>Please help.</p>
  
  <p><a href="https://i.stack.imgur.com/UTpZP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UTpZP.png" alt="Error"></a></p>