title: RXJS How do I use the result of one observable in another (and then process those two results together)
body: <p>A very common problem when using RxJs seems to be to want the result of one or more observables to then use them in subsequent ones.</p>
  
  <p>e.g. in pseudo-code (This is not rx or valid js syntax deliberately)</p>
  
  <pre><code>var someResult = $observable-A; // wait to complete
  var finalResult = $observable-B(someResult.aValueINeed);
  </code></pre>
  
  <p>This can be done in an ugly way where you could subscribe to both and call one inside the other.. however, this is very messy and doesn't afford you much flexibility.</p>
  
  <p>e.g. (real syntax)</p>
  
  <pre><code>$observable-A.subscribe(resultA =&gt; { 
      $observable-B(resultA.aValueINeed)
          .subscribe(resultB =&gt; { 
              console.log('After everything completes: ', resultB); 
          }
  }
  </code></pre>
  
  <p>This also means that nothing else can easily consume this stream as you're completing both of the observables.</p>
  
  <p>My specific use case requires the following:</p>
  
  <ol>
  <li>An initial call to get $observable-A as it doesn't require anything else (it's a basic http GET call)</li>
  <li>An http GET call to another service that requires data from $observable-A, which returns $observable-B</li>
  <li>Using both observable results (A + B) to create an object for my service (In my case, an Angular service) to return a single list.</li>
  </ol>
  
  <blockquote>
    <p>I also need to be able to subscribe to this function inside my service, this is why going with the subscribe method above, won't work for me.</p>
  </blockquote>