title: RxJs Observable: Execute function if empty/filtered
body: <p>I've got an Observable that listens to some user input from a text box. If the observed string's length is >=3 (<code>filter</code>), it executes some HTTP call (<code>switchMap</code>). </p>
  
  <p>Now I'd like to detect somehow if the user input has been filtered. Reason:</p>
  
  <ul>
  <li><p>If the HTTP call has been done, it should show the results.</p></li>
  <li><p>If the user input got filtered (== is invalid), it should clear the results.</p></li>
  </ul>
  
  <p>Here's the code I'd like to have (see: <code>ifFiltered</code>):</p>
  
  <pre><code>this.userInput.valueChanges
      .filter(val =&gt; val &amp;&amp; val.length &gt;= 3)
      .ifFiltered(() =&gt; this.results = [])
      .switchMap(val =&gt; getDataViaHTTP())
      .subscribe(val =&gt; this.results = val);
  </code></pre>
  
  <p>I know, I could place that logic within the <code>filter</code> function for this simple example. But what if I have 10 different filters?</p>
  
  <p>Did I miss any method that satisfies my needs?</p>
  
  <p>Thanks in advance!</p>