title: Combining multiple observables and acting when at least one value is returned in Angular
body: <p>I have a set of observables and I'll need to react when the last one has provided a value (whichever that one will be).</p>
  
  <p>My first approach was <a href="http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html#static-method-forkJoin" rel="nofollow noreferrer"><em>forkJoin</em></a> like this.</p>
  
  <pre><code>const observables = [
    this.backend.config(),
    this.navigation.location()
  ];
  
  forkJoin(observables)
    .subscribe(([backend, selection]) =&gt; {
      console.log(backend);
      console.log(selection);
    });
  </code></pre>
  
  <p>This worked partly as long as the observables emit <em>complete</em> at some point (upon which, the finalization is invoked. Then I tried <a href="http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html#static-method-combineLatest" rel="nofollow noreferrer"><em>combineLatest</em></a>. That resolved the original issue but created a new one. Now, I get the final method invoked as soon as <strong>any</strong> of the observables provides.</p>
  
  <p>I'd like to get it invoked when each of the observables has provided at least once and might or might not have completed. It doesn't mater if it's the latest value from each or if it's the first one. Although, it might be a plus to learn how to control that as well for +1.</p>
  
  <p>The best, yet hacky, solution I came up with is to check <em>!!backend</em> and <em>!!navigation</em> and only act if all of them satisfy. I'm looking for a smoother solution or confirmation that the one I'm using is as good as it gets.</p>
  
  <pre><code>combineLatest(observables)
    .subscribe(([a, b, c]) =&gt; {
      if (!a || !b || !c)
        console.log("Oh, I'm coming...");
      else
        console.log("Wham, bam - I'm done!");
    });
  </code></pre>
  
  <p>All that from blogs <a href="https://www.metaltoad.com/blog/angular-6-upgrading-api-calls-rxjs-6" rel="nofollow noreferrer">like this</a> or <a href="https://www.learnrxjs.io/operators/combination/forkjoin.html" rel="nofollow noreferrer">that</a>, <a href="https://stackoverflow.com/a/45172164/1525840">posts on SO</a> and <a href="http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html#static-method-combineLatest" rel="nofollow noreferrer">Observables' docs</a>.</p>