RxJS 5.0 "do while" like mechanism
<p>I'm trying to use RxJS for a simple short poll. It needs to make a request once every <code>delay</code> seconds to the location <code>path</code> on the server, ending once one of two conditions are reached: either the callback <code>isComplete(data)</code> returns true or it has tried the server more than <code>maxTries</code>. Here's the basic code:</p>

<pre><code>newShortPoll(path, maxTries, delay, isComplete) {
    return Observable.interval(delay)
    .take(maxTries)
    .flatMap((tryNumber) =&gt; http.get(path))
    .doWhile((data) =&gt; !isComplete(data));
  }
</code></pre>

<p>However, doWhile doesn't exist in RxJS 5.0, so the condition where it can only try the server <code>maxTries</code> works, thanks to the take() call, but the <code>isComplete</code> condition does not work. How can I make it so the observable will next() values until isComplete returns true, at which point it will next() that value and complete().</p>

<p><strong>I should note that <code>takeWhile()</code> does not work for me here. It does not return the last value, which is actually the most important, since that's when we know it's done.</strong></p>

<p>Thanks!</p>