Last Updated on: (senast uppdaterad på:)
Use forkJoin to subscribe to more than one observable simultaneously
forkJoin( this.service.service1(), this.service.service2(), this.service.service3() ).subscribe((res) => { this.funcA(res[0], res[1], res[2]); });
Another example is:
forkJoin( this.logic10Service.getLogic10(this.item_id), this.http.get<ILogic10BaseCategory[]>(this.catsUrl_part1 + this.item_id + this.CatsUrl_part2) ).subscribe((res) => { console.log("- forkJoin returned " + res[0] + ", and " + res[1]); //can start interacting with res[0] and res[1] })
For more, see https://stackoverflow.com/questions/52317494/is-it-good-way-to-call-subscribe-inside-subscribe