title: RxJS need shareReplay with default value
body: <p>The problem is that <code>startWith</code> and <code>shareReplay</code> combine poorly.</p>
  
  <p>If you use <code>source.startWith(0).shareReplay(1)</code>, new subscriptions will always start with <code>0</code> , and <code>shareReplay</code> is meaningless, <code>source.shareReplay(1).startWith(0)</code> works slightly better, but result in new subscriptions to receive two values.</p>
  
  <p>Expected:</p>
  
  <pre><code>source ---1---2----3---4----5
  ob1    0--1---2----3---4----5
  ob2             2--3---4----5
  </code></pre>
  
  <p>Update: Seems like my minimized case was too minimized. My problem is that i switch from <code>ob1</code> to <code>ob2</code> using <code>switch</code>, what means <code>ob1</code> will unsubscribe right before <code>ob2</code> subscribes. Weirdly enough it does work correctly if i use just <code>shareReplay(1)</code>, but the combination of <code>startWith(0).shareReplay(1)</code> does not.</p>
  
  <pre><code>const main$ = new Rx.Subject()
  const s1$ = new Rx.Subject()
  
  
  // Expected:
  // 0 1 2 2 3 4
  
  //const s2$ = s1$.shareReplay(1).startWith(0)
  // got: 
  // 0 1 2 0 2 3 4
  
  //const s2$ = s1$.startWith(0).shareReplay(1)
  // got:
  // 0 1 2 2 0 3 4
  
  const s2$ = s1$.shareReplay(1)
  // got:
  // 1 2 2 3 4
  
  main$.switch()
    .subscribe(
      v =&gt; console.log("1: " + v)
    )
  
  main$.onNext(s2$)
  s1$.onNext(1)
  s1$.onNext(2)
  
  main$.onNext(s2$)
  
  s1$.onNext(3)
  s1$.onNext(4)
  </code></pre>