RxJs Multiple Subscriptions

JS
S
JavaScript

Wait for multiple subscriptions to arrive (analogous to Promise.all). Please be reminded that Stream variables are suffixed with $. * If you are working on an Angular project, the DOM element bind component will internally accomplish this for you.

1import { forkJoin } from 'rxjs/observable/forkJoin';
2import { combineLatest } from 'rxjs/observable/combineLatest';
3
4const values$ = combineLatest(
5    this.service.getFinanceTotals('category', this.formatDate(this.monthCurrent)),
6    this.service.getFinanceTotals('category', this.formatDate(this.monthPrevious))
7).pipe(
8    map(([current, previous]) => {
9    return { current, previous };
10    })
11);
12
13values$
14    .subscribe(data => {
15
16    });

Created on 8/27/2018