title: Merging unknown number of observables with RxJS
body: <p>I am currently trying to create a small project to demo Reactive Programming with RxJS. The goal is to show my colleagues that this thing is out there, and it is worth looking into. I'm not experienced with the framework, so that makes things complicated.</p>
  <p>I am trying to expand another demo of mine to utilize RxJS.
  It is not a very complicated demo, basically I can add any number of small forms, which result in a number calculated by a small formula, and there is a button, which sums up the values of all the forms.</p>
  <p>Getting the formula calculate inside the forms is easy, but I figured I could go further.</p>
  <p>I want to have the sum operation done automatically through a merged observable.
  The only solution I figured out is something along these lines:</p>
  <pre><code>//dummy observables
  var s1 = Rx.Observable.Interval(100);
  var s2 = Rx.Observable.Interval(200);
  
  //Combine the observables
  var m = s1.combineLatest(s2, function(x,y){return x+y});
  
  //Subscribe to the combined observable
  var sub = m.subscribe(function(x){console.log(x)});
  //A new observable is created
  var s3 = Rx.Observable.Interval(300);
  //Now I need to update all my subscriptions, wich is a pain.
  m = m.combine(s3, function(x,y){return x+y});
  sub.dispose();
  sub=m.subscribe(function(x){console.log(x)});
  </code></pre>
  <p>I figured I could get another observable to notify my subscriptions to update themselves - as knowing how all my subscribers work would render the whole architecture useless, but this sounds like an overkill for a task like this, and I don't just mean the demo, I can't really imagine to have an &quot;every day&quot; real world example where an architecture like this would make things cleaner than just watching for any change, and getting the calculated values &quot;actively&quot; from my forms.</p>
  <p>I'd probably do the active getting, and summing of values inside the module handling the forms, and have the &quot;m&quot; observable for the outside world to subscribe to, pushing my values into it from inside the module.</p>
  <p>Would this be a correct approach? I'd think yes, because they are owned by my module, I'm supposed to have full control over what is happening to them, but I'm really interested in what more experienced people think about this.</p>