title: RXJS Combining multiple observables inside a pipe
body: <p>I have an API call that returns a certain amount of ids. 
  Each of these ids are used to make a new api call. The results of these API calls need to be combined into a single object.</p>
  
  <p>At first I used a loop inside the .pipe(map) operator of the first api call. In this loop I did the second api calls, and in the .pipe(map) operator in each of these calls I would edit a variable in my angular component.</p>
  
  <p>This wasn't very pretty, and I was actually wondering if this is thread safe. I know javascript is single threaded, but it doesn't seem very safe to have multiple asynchronous processes messing with the same global variable.</p>
  
  <p>after that I just stored the observable returned by the second api call in an  array by looping over the returned Ids by apiCall1, and used forkJoin to subscribe and handle each result accordingly (see example).</p>
  
  <p>This isn't very pretty however, and I was wondering if there's an operator I can use in my pipe for this?</p>
  
  <p>So instead of (pseudocode):</p>
  
  <pre><code>  .pipe(
        map(ids=&gt; {
  
          let observables = []
          for (const id of ids) {
           observables.push(this.service.getSomeStuff(id));
          }
  
          forkJoin(...observables).subscribe(dataArray) =&gt; {
            for (data of dataArray) {
              //Do something
            }
          });
  
        }),
        takeWhile(() =&gt; this.componentActive),
        catchError(error =&gt; {
          console.log(error);
          return throwError(error);
        })
      )
      .subscribe();
  </code></pre>
  
  <p>Is there an operator that makes it something like this:</p>
  
  <pre><code>  .pipe(
        map(ids=&gt; {
  
          let observables = []
          for (const id of ids) {
           observables.push(this.service.getSomeStuff(id));
          }
  
        return observables
        }),
        forkJoin(dataArray =&gt; {
            for (data of dataArray) {
              //Do something
            }
          });
        takeWhile(() =&gt; this.componentActive),
        catchError(error =&gt; {
          console.log(error);
          return throwError(error);
        })
      )
      .subscribe();
  </code></pre>