title: RxJS design pattern for multiple async calls
body: <p>I am new to RxJS and haven't been able to find clear answers on the following use case:</p>
  
  <p>In a mobile app (Angular/Ionic), I need to (1) make simultaneous HTTP calls and only return data when all have completed (like $q.all). I want to (2) throw an error if the calls work correctly but there is a nested value in one of the responses that meets a certain criteria (ie user is not authenticated properly). Because it's a mobile app, I want to (3) build in a few retry attempts if the calls don't work correctly (for any reason). If after a certain number of retry attempts the calls still fail, I want to (4) throw an error. </p>
  
  <p>Based on my research seems like forkJoin works the same as q.all. I have a provider that returns the following (observableArray holds the http calls). </p>
  
  <pre class="lang-js prettyprint-override"><code>return Observable.forkJoin(observableArray)
  </code></pre>
  
  <p>And then I can pipe in some operators, which is where I'm starting to struggle. For checking the nested value (2), I am using an underscore method to iterate over each response in my response array. This doesn't seem clean at all. </p>
  
  <p>For retrying the calls (3), I am using retryWhen and delayWhen. But I am unsure how to limit this to 3 or 4 attempts. </p>
  
  <p>And if the limit is hit, how would I throw an error back to the subscribers (4)?</p>
  
  <pre class="lang-js prettyprint-override"><code>.pipe(
      map(
          res =&gt; {
              _.each(res, (obs) =&gt; {
                  if (!obs['success']) throw new Error('success was false')
              })
          }
      ),
      retryWhen(attempts =&gt;
          attempts.pipe(
              tap(err =&gt; console.log('error:', err),
                  delayWhen(() =&gt; timer(1000))
              )
          )
      ))
  </code></pre>