title: rxjs, recursively call api until all items are fetched
body: <p>I need to call an api and fetch all items from an endpoint. However we can only fetch 100 items at a time.</p>
  
  <p>The response looks like this:</p>
  
  <pre><code>{
      elements: Array&lt;any&gt;,
      totalCount: number,
  }
  </code></pre>
  
  <p>and the endpoint would be <code>/api/items?drop=${drop}&amp;take=100</code> with <code>drop</code> being used to paginate.</p>
  
  <p>I think that would involve the scan and takeWhile operators somewhere.. Here is what I got:</p>
  
  <pre><code>    const subject = new Subject();
      const rec = subject.pipe(
          scan((acc: number, curr: number) =&gt; (curr + 100), 0),
          switchMap(drop =&gt; this.http.get(`api/items?drop=${drop}&amp;take=100`)),
          takeWhile((r: any) =&gt; r.elements.length === 100),
          tap(r =&gt; subject.next())
      );
  </code></pre>