Try using combineLatest instead of forkJoin :
With combineLatest :
const combined = Observable.combineLatest( this.http.get('https://testdb1.firebaseio.com/.json').map((res: Response) => res.json()), this.http.get('https://testdb2.firebaseio.com/.json').map((res: Response) => res.json()) ) combined.subscribe(latestValues => { const [ data_changes , data_all ] = latestValues; console.log( "data_changes" , data_changes); console.log( "data_all" , data_all); });
You can also handle it with forkJoin, but forkJoin will return data when all calls are completed and return the result, but in combLatest. When any observable emits a value, emits the last value from each.
With forkJoin :
const combined = Observable.forkJoin( this.http.get('https://testdb1.firebaseio.com/.json').map((res: Response) => res.json()), this.http.get('https://testdb2.firebaseio.com/.json').map((res: Response) => res.json()) ) combined.subscribe(latestValues => { const [ data_changes , data_all ] = latestValues; console.log( "data_changes" , data_changes); console.log( "data_all" , data_all); });
Call both and check the console log, you get a view.
Vivek doshi
source share