title: How to use the result of previous observable chain?
body: <p>After some flatMap chain, I want use all previous result in the end, suppose I have the following code:</p>
  
  <pre><code>func getObservable1() -&gt; Observable&lt;API1Response&gt; {
  
      ...
  }
  
  func getObservable2(param: API1Response) -&gt; Observable&lt;API2Response&gt; {
  
      ...
  }
  
  func getObservable3(param: API2Response) -&gt; Observable&lt;API3Response&gt; {
  
      ...
  }
  
  getObservable1()
      .flatMap { api1Response in
          return getObservable2(api1Response) 
      }
      .flatMap { api2Response in
          return getObservable3(api2Response) 
      }
      .subscribe(onNext: { api3Response  in
          // I want to use both of api1Response and api2Response here
      })
  </code></pre>
  
  <p>How can I do that?</p>
  
  <p>Should I save the api response to out scope variable and then use its latter?</p>
  
  <p>Something like:</p>
  
  <pre><code>var api1Response: API1Response?
  func getObservable1() -&gt; Observable&lt;API1Response&gt; {
      ...
  
      self.api1Response = api1Response
      ...
  }
  ...
  getObservable1()
      ...
      .subscribe(onNext: { api3Response  in
          // use ap1Response here
          print(self.api1Response)
      })
  </code></pre>
  
  <p>Thanks!</p>
  
  <p>-----UPDATE-----</p>
  
  <p>Base on @Misternewb answer, I post runable code for test.</p>
  
  <pre><code>func getObservable1() -&gt; Observable&lt;Int&gt; {
      return Observable.of(1)
  }
  
  func getObservable2(num: Int) -&gt; Observable&lt;Int&gt; {
      return Observable.of(num + 1)
  }
  
  func getObservable3(num: Int) -&gt; Observable&lt;Int&gt; {
      return Observable.of(num + 10)
  }
  
  
  getObservable1()
      .flatMap { ret1 in
          return getObservable2(num: ret1).map { (ret1, $0) }
      }
      .flatMap { ret1, ret2 in
          return getObservable3(num: ret2).map { (ret1, ret2, $0) }
      }
      .subscribe(onNext: { ret1, ret2, ret3 in
          print(ret1)
          print(ret2)
          print(ret3)
      })
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>1
  2
  12
  </code></pre>