title: RxJava tricky startWith(Observable)
body: <p>The following code emits items from observable1 only after observable2 is completed. </p>
  
  <pre><code>observable1.startWith(observable2)
             .subscribe()
  </code></pre>
  
  <p>I need to achieve another behavior</p>
  
  <pre><code>observable1 -&gt;       0   1   2   3
  observable2 -&gt; 1   2   3   4   5   6
  
  observable1.startWithDefault(observable2)
              -&gt; 1   2 0   1   2   3
  </code></pre>
  
  <p>The second observable emits items only while first observable is empty and then items from first one are emited.</p>
  
  <p>I could not find correct solution using only basic operators, what is correct RxJava 2 implementation of custom operator startWithDefault should look like?</p>
  
  <p>P.S.</p>
  
  <pre><code>observable1.subscribe()
  observable2.takeUntil(observable1).subscribe()
  </code></pre>
  
  <p>is not correct solution because of race in case of immediate emit from observable1</p>