Join Angular Observables

Posted 08/17/2017 4:11 PM by Corey Klass

If you have multiple observables that you want to execute simultaneously, and be notified when they've completed, you use the Observable.forkJoin() function, passing it an array of Observables:

const observable1 = this.http.get('url1.html');
const observable2 = this.http.get('url2.html');

Observable.forkJoin([observable1, observable2]).subscribe(results => {
  const results1 = results[0]; // observable1 results
  const results2 = results[1]; // observable2 results