Both async and forkJoin.subscribe create separate network requests.
Use Observable.share to prevent re-subscription
this.highlightedInsight = this.insightService.getHighlightedInsight().share() this.insights = this.insightService.getInsightsList().share() this.topics = this.insightService.getInsightTopicsList().share() Observable.forkJoin([ this.highlightedInsight, this.insights, this.topics ]).subscribe( response => {}, error => { console.log('An error occurred:', error); }, () => { this.loading = false; });
But since the results are not needed until the end (when !loading ), this can be simplified:
Observable.forkJoin([ this.insightService.getHighlightedInsight(), this.insightService.getInsightsList(), this.insightService.getInsightTopicsList() ]).subscribe( ([highlightedInsight, insights, topics]) => { this.highlightedInsight = highlightedInsight; this.insights = insights; this.topics = topics; }, error => { console.log('An error occurred:', error); } );
HTML:
<div class="internal-wrapper"> <app-highlighted-insight [insight]="highlightedInsight"></app-highlighted-insight> <app-topic-filter [topics]="topics"></app-topic-filter> <app-insight-list [insights]="insights"></app-insight-list> </div>
source share