title: Filtering RxJS stream after emission of other observable until timer runs out
body: <p>I want to achieve the following behavior in RxJS but could not find a way using the available operators:</p>
  <ul>
  <li><strong>Stream A</strong>: Generated by a continuous stream of events (e.g. browser scroll)</li>
  <li><strong>Stream B</strong>: Generated by another arbitrary event (e.g. some kind of user input)</li>
  <li>When <strong>B</strong> emits a value, I want to pause the processing of <strong>A</strong>, until a specified amount of time has passed. All values emitted by A in this timeframe are thrown away.</li>
  <li>When <strong>B</strong> emits another value during this interval, the interval is reset.</li>
  <li>After the interval has passed, the emitted values of <strong>A</strong> are no longer filtered.</li>
  </ul>
  <pre><code>// Example usage.
  streamA$
    .pipe(
      unknownOperator(streamB$, 800),
      tap(val =&gt; doSomething(val))
    )
  // Output: E.g. [event1, event2, &lt;skips processing because streamB$ emitted&gt;, event10, ...]
  
  // Operator API.
  const unknownOperator = (pauseProcessingWhenEmits: Observable&lt;any&gt;, pauseIntervalInMs: number) =&gt; ...
  
  </code></pre>
  <p>I thought that <a href="https://rxjs.dev/api/operators/throttle" rel="nofollow noreferrer"><code>throttle</code></a> could be used for this use case, however it will not let any emission through, until <strong>B</strong> has emitted for the first time (which might be never!).</p>
  <pre><code>streamA$
    .pipe(
      // If B does not emit, this never lets any emission of A pass through!
      throttle(() =&gt; streamB$.pipe(delay(800)), {leading: false}),
      tap(val =&gt; doSomething(val))
    )
  </code></pre>
  <p>An easy hack would be to e.g. subscribe manually to B, store the timestamp when a value was emitted in the Angular component and then filter until the specified time has passed:<br />
  (obviously goes against the side-effect avoidance of a reactive framework)</p>
  <pre><code>streamB$
    .pipe(
      tap(() =&gt; this.timestamp = Date.now())
    ).subscribe()
  
  streamA$
    .pipe(
      filter(() =&gt; Date.now() - this.timestamp &gt; 800),
      tap(val =&gt; doSomething(val))
    )
  </code></pre>
  <p>I wanted to check with the experts here if somebody knows an operator (combination) that does this without introducing side-effects, before I build my own custom operator :)</p>