title: Wait for n executions of a method and then continue after complete
body: <p>I have a function that returns promise:</p>
  
  <pre><code>Setup.zoomIn() : Promise&lt;void&gt; {...}
  </code></pre>
  
  <p>I would like to use rxjs to invoke that function 5 times with delay of 1 second between each, like this:</p>
  
  <pre><code>let obs = Observable.create(observer =&gt; {
    let count = 0; 
    setTimeout(() =&gt; {
       Setup.zoomIn();
       count++;
       observer.next();          
    }, 1000);
    if (count === 5) {observer.complete();}
  };
  
  obs.subscribe(() =&gt;
     console.log('zoomed out');
  )};
  </code></pre>
  
  <p>Only and only when that is executed I would like to continue with execution to perform further steps:</p>
  
  <pre><code>obs.toPromise.then(() =&gt; {
     // do some stuff here but only after zoom has been invoked 5 times
  })
  </code></pre>