title: RxJs Conditional Debounce and Sampling
body: <p>Conditional adding debounce time to a stream based on value from other stream</p>
  
  <pre><code>const configuration$ = new Subject().asObservable();
  const animation$ = new BehaviorSubject(false).asObservable;
  </code></pre>
  
  <p>the above comes from some service</p>
  
  <pre><code>configuration$.pipe(debounceTime(CONSTANTS.DEBOUNCE),sample(interval(CONSTANTS.SAMPLE)));
  
  configuration.subscribe(data=&gt; {
     // do the stuff; 
  });
  
  
  </code></pre>
  
  <p>If animation$ has true value then <code>debounceTime</code>, <code>sample</code> should be skipped.</p>
  
  <p>How can I extract value from animation$ and apply if else logic.</p>
  
  <p>If only I can do</p>
  
  <pre><code> configuration$.pipe(
      animation$ ? 
      pipe(debounceTime(CONSTANTS.DEBOUNCE),sample(interval(CONSTANTS.SAMPLE))) :
      of
  );
  </code></pre>