title: Observable.forkJoin with a for loop
body: <p>I am trying to populate an array in my component called <code>processes</code> which is an array of <code>process</code>. Each <code>process</code> also has a list of <code>tasks</code>.</p>
  
  <p>So currently, I am working with two api calls which are:</p>
  
  <p><code>/processes</code> 
  and
  <code>/process/{processId}/tasks</code></p>
  
  <p>I use <code>/processes</code> to get all the processes and initially populate the <code>processes</code> array. Then I use the process id of each <code>process</code> to call the second API to get the tasks of that process. </p>
  
  <p>Currently, my code looks something like this: </p>
  
  <pre><code>this.processes.forEach((process, index) =&gt; {
      myService.getTasks().subscribe((tasks) =&gt; {
          process.tasks = tasks;
      })
  })
  </code></pre>
  
  <p>I understand that I can create an array of observables, and use <code>Observable.forkJoin()</code> to wait for all these async calls to finish but I want to be able to define the subscribe callback function for each of the calls since I need a reference to the <code>process</code>. Any ideas on how I can go about approaching this issue?</p>