title: Angular RxJS: conditional operator (if else)
body: <p>I'm trying to figure out how to implement a straightforward condional operation into an observable.</p>
  
  <pre><code>this.deactivate$
      .pipe(
          filter((canDeactivate) =&gt; !canDeactivate),
          switchMap(() =&gt; Observable.of(window.confirm("message")))
      );
  </code></pre>
  
  <p>What I want to get is that:</p>
  
  <pre><code>if (canDeactivate) {
      return canDeactivate;
  }
  else {
      return window.confirm("message");
  }
  </code></pre>
  
  <p>The problem on first above code is that when I'm filtering emitted value, the rest of operators are not performed and stream stops to populate emitted value.</p>
  
  <p>Any ideas?</p>