title: How to restart rxjs interval?
body: <p>I created a class which sets up a pausable RxJS <code>Observable</code> using the <code>interval</code> operator:</p>
  <pre><code>export class RepeatingServiceCall&lt;T&gt; {
    private paused = false;
    private observable: Observable&lt;T&gt;;
    constructor(serviceCall: () =&gt; Observable&lt;T&gt;, delay: number) {
      this.observable = interval(delay).pipe(flatMap(() =&gt; (!this.paused ? serviceCall() : NEVER)));
    }
    setPaused(paused: boolean) {
      this.paused = paused;
    }
    getObservable() {
      return observable;
    }
  }
  </code></pre>
  <p>This seems to work fine, but the problem I am trying to solve is that I want the timer to reset when unpaused. So, let's say that the <code>interval</code> time is 10 seconds and 5 seconds after the last time the <code>interval</code> emitted, <code>setPaused(false)</code> is called. In that scenario, I want it to emit immediately and then restart the timer.</p>
  <p>Would something like that be an easy thing to add?</p>