title: How to store accumulated result of a scan with rxjs
body: <p>I have two merged observables with a scan after the merge. The first one is a simple range and the other is a Subject. Whenever the Subject emits a new value with <code>onNext</code> I concatenate that value in the scan and return the new array as the accumulator. If I dispose of my subscription, and then subscribe again it replays the values from the range but I have lost the ones from the Subject. In the code below I want my second subscription to have a final value of <code>[1, 2, 3, 4, 5]</code></p>
  
  <p>What would be the best way to do this? Right now I have another Subject where I store that final value and subscribe to that, but it <em>feels</em> wrong.</p>
  
  <p>Here's a simple version that demonstrates what is happening:</p>
  
  <pre><code>var Rx = require('rx');
  
  var source = Rx.Observable.range(1, 3);
  
  var adder = new Rx.Subject();
  
  var merged = source.merge(adder)
                      .scan([], function(accum, x) {
                          return accum.concat(x);
                      });
  
  var subscription1 = merged.subscribe(function(x) {console.log(x)});
  adder.onNext(4);
  adder.onNext(5);
  
  subscription1.dispose();
  
  console.log('After Disposal');
  
  var subscription2 = merged.subscribe(function(x) {console.log(x)});
  </code></pre>
  
  <p>This outputs:</p>
  
  <pre><code>[ 1 ]
  [ 1, 2 ]
  [ 1, 2, 3 ]
  [ 1, 2, 3, 4 ]
  [ 1, 2, 3, 4, 5 ]
  After Disposal
  [ 1 ]
  [ 1, 2 ]
  [ 1, 2, 3 ]
  </code></pre>