title: Rxjava2 - multi retrofit request and handle all exception
body: <p>I am new to Rxjava. It is so complex......</p>
  
  <p>I need to handle a complex scenario, I want to know how to make it using Rxjava.</p>
  
  <p>It's a logic about app start:</p>
  
  <ol>
  <li>app start and <code>splash</code> page open</li>
  <li>make http reqesut <code>check_update</code> to check if app need update.</li>
  <li>if app has new version and must update, pop up a notice dialog with only one <code>update</code> button; if app has new version, but not must update, then pop up a dialog with 2 button(<code>update</code> and <code>ignore</code>); if no new version, go next.</li>
  <li>no need to update, so we need to jump to <code>home</code> page or <code>login</code> page, according to current <code>auth_token</code> state. </li>
  <li>read <code>auth_token</code> from sharedPreference. then call http request <code>check_auth</code> to check if it is valid or not. if valid, jump to <code>home</code> page; if not, jump to <code>login</code> page.</li>
  </ol>
  
  <p>In this process, 2 http requests and lots of condition checks are involved. http request error also need to be handled, Can this process be written in one <code>Rxjava</code>?</p>
  
  <p>I think I can do it in this way, but I am not sure if it is right.</p>
  
  <pre><code>mRetrofitService.checkUpdate(new CheckUpdateRequest("android", "0.0.1")) // check update request
              .compose(RxUtil.applyScheduler()) // scheduler
              .flatMap(RxUtil.applyFunction()) // handle the response.
              .flatMap((Function&lt;CheckUpdateResponse, ObservableSource&lt;?&gt;&gt;) checkUpdateResponse -&gt; {
                  int updateMode;
                  if (checkUpdateResponse.isHas_new_version()) {
                      if (checkUpdateResponse.isForce_update()) {
                          updateMode = FORCE_UPDATE; // 1
                      } else {
                          updateMode = CHOOSE_UPDATE; // 2
                      }
                  }  else {
                      updateMode = NO_UPDATE; // 0
                  }
                  return Observable.just(updateMode);
              })
              .flatMap(o -&gt; {
                  if (Integer.parseInt(o.toString()) == NO_UPDATE) {
                      return mRetrofitService.checkAuth();
                  }
                  return null; //what should I return for pop up dialog?
              })
              .flatMap(RxUtil.applyFunction())
              .subscribe(new Observer&lt;CheckAuthResponse&gt;() {
                  @Override
                  public void onSubscribe(Disposable d) {
  
                  }
  
                  @Override
                  public void onNext(CheckAuthResponse checkAuthResponse) {
                      // valid
                      gotoHome();
                  }
  
                  @Override
                  public void onError(Throwable e) {
                      // should I handle pop here?
                      // should I handle auth invalid here?
                      // should I handle checkUpdate request error here?
                      // should I handle checkAuth here?
                      // how to distinguish these errors?
                  }
  
                  @Override
                  public void onComplete() {
  
                  }
              });
  </code></pre>
  
  <p>Am I right? And would you please answer my questions(comments in the code)?</p>