title: accumulating values such as with scan but with the possibility to reset the accumulator over time
body: <p>I have one Observable, <strong>obs1</strong>, which represents a stream of numbers over time. I need to accumulate the sum of such numbers and emit it progressively (i.e. a long way to say I need to use <code>scan</code> operator).</p>
  
  <p>Then there is a second Observable, <strong>obs2</strong>, that represents some sort of "reset time". In other words, when <strong>obs2</strong> emits, I have to reset the accumulator I have set on <strong>obs1</strong> and start summing from 0.</p>
  
  <p>I think I have been able to reach the behavior I want with the following code, but I am not sure it is the right way to do it (it sorts of smells to me)</p>
  
  <pre><code>const obs1 = Observable.interval(100).mapTo(1).take(100);
  
  const obs2 = Observable.interval(700).take(10);
  
  obs1.pipe(
      windowWhen(() =&gt; obs2),
      mergeMap(d =&gt; d.pipe(scan((acc, one) =&gt; acc + one, 0)))
  )
  .subscribe(console.log);
  </code></pre>
  
  <p>Any suggestion on how to improve it?</p>