title: RxJava: call function when two observables with different result types are completed
body: <p>I'm working on an Android application that retrieves two different objects via an API that I access via RxJava Observables. To update the UI, I need <em>both</em> results.</p>
  
  <p>How can I run a function as soon as both Observables have completed? It seems like functions like <code>merge</code> are doing what I'm planning, but as far as I can see they only work for Observables with the same result type or need a composite object that can represent both types.</p>
  
  <p>A simple example:</p>
  
  <pre><code>Observable.just("Hello world")
          .subscribe(new Action1&lt;String&gt;() {
              @Override
              public void call(String s) {
                  System.out.println(s);
              }
          });
  Observable.just(1, 2, 3, 4, 5, 6)
          .subscribe(new Action1&lt;Integer&gt;() {
              @Override
              public void call(Integer i) {
                  System.out.println(i);
              }
          });
  </code></pre>
  
  <p>What would I need to do to run <code>System.out.println("Finished!")</code> as soon as both Observables have completed their task?</p>
  
  <p>In the particular case of my Android application, I could simply store the results in the actual class, have an updateUi function that only does work when all required data already arrived and call this function from both onCompleted calls, but I feel there is a better way.</p>