RXJava2: correct pattern to chain retrofit requests : <p>I am relatively new to RXJava in general (really only started using it with RXJava2), and most documentation I can find tends to be RXJava1; I can usually translate between both now, but the entire Reactive stuff is so big, that it's an overwhelming API with good documentation (when you can find it). I'm trying to streamline my code, an I want to do it with baby steps. The first problem I want to solve is this common pattern I do a lot in my current project: </p>

<p>You have a Request that, if successful, you will use to make a second request. </p>

<p>If either fails, you need to be able to identify which one failed. (mostly to display custom UI alerts).</p>

<p>This is how I usually do it right now: </p>

<p>(omitted the <code>.subscribeOn/observeOn</code> for simplicity)</p>

<pre><code>Single&lt;FirstResponse&gt; first = retrofitService.getSomething();

first
   .subscribeWith(
     new DisposableSingleObserver&lt;FirstResponse&gt;() {
         @Override
         public void onSuccess(final FirstResponse firstResponse) {

               // If FirstResponse is OK…
                Single&lt;SecondResponse&gt; second = 
                 retrofitService
                    .getSecondResponse(firstResponse.id) //value from 1st
                    .subscribeWith(
                      new DisposableSingleObserver&lt;SecondResponse&gt;() {

                           @Override
                           public void onSuccess(final SecondResponse secondResponse) {
                              // we're done with both!
                           }

                           @Override
                            public void onError(final Throwable error) {
                            //2nd request Failed, 
                            }                        
                     });

         }

         @Override
         public void onError(final Throwable error) {
              //firstRequest Failed, 
         }
      });
</code></pre>

<p>Is there a better way to deal with this in RXJava2?</p>

<p>I've tried <code>flatMap</code> and variations and even a <code>Single.zip</code> or similar, but I'm not sure what the easiest and most common pattern is to deal with this. </p>

<p>In case you're wondering FirstRequest will fetch an actual <code>Token</code> I need in the SecondRequest. Can't make second request without the token. </p>
