title: How do I create an Observable after another has finished, and combine the results
body: <p>I have: </p>
  
  <ul>
  <li><code>Observable&lt;T1&gt; a</code></li>
  <li><code>Supplier&lt;Observable&lt;T2&gt;&gt; p</code></li>
  <li><code>Function&lt;T1, R&gt; f</code> </li>
  <li><code>Function&lt;T2, R&gt; g</code>. </li>
  </ul>
  
  <p>I would like to sequence <code>a</code> and <code>p.get()</code> as follows: </p>
  
  <ul>
  <li>Wait for <code>a</code> to complete, then call <code>Observable&lt;T2&gt; b = p.get()</code></li>
  <li>Map the values of <code>a</code> and <code>b</code> to type <code>R</code> using <code>f</code> and <code>g</code></li>
  <li>Return the result as an <code>Observable&lt;R&gt;</code></li>
  <li>The result should fail when either <code>a</code> or <code>b</code> fails </li>
  <li>It should complete after <code>b</code> has finished. </li>
  </ul>
  
  <p>This is what I have tried so far (ignoring <code>f</code> and <code>g</code>): </p>
  
  <pre><code>public static &lt;T&gt; Observable&lt;T&gt; sequence(final Observable&lt;? extends T&gt; a, final Supplier&lt;Observable&lt;? extends T&gt;&gt; p) {
  
      final Subject&lt;T&gt; subject = PublishSubject.create();
  
      a.subscribe(
          subject::onNext,
          subject::onError,
          () -&gt; {
              p.get().subscribe(
                  subject::onNext,
                  subject::onError,
                  subject::onComplete);
          });
  
      return subject;
  }
  </code></pre>
  
  <p>How should I implement this? </p>