I've seen all the example of using forkJoin with get requests, but all of them use the get directly in the forkJoin. Is it possible to pass in the data service function into the forkJoin? Currently, it is not working for me and I'm just curious if I'm simply missing something.
Here is my current code:
forkJoin([this._dataService.getTradeLetterTotals(this.selectedPlannedBy.PlannedBy_ID, this.selectedProductGroup.Product_Group_ID, 1),
this._dataService.getTradeLetterTotals(this.selectedPlannedBy.PlannedBy_ID, this.selectedProductGroup.Product_Group_ID, 2)]).subscribe((results: any) => {
console.log(results);
this.tradeLetterFullYearData = results[0].data
this.tradeLetterAdjPeriodData = results[1].data
this.isTradeLetterFullYearFinished = true;
this.checkRemoveLoading();
});
getTradeLetterTotals(plannedByID, productGroupID, timePeriodID) {
let cmd = "TradeLetter/Totals/" + plannedByID + "/" + productGroupID + "/" + timePeriodID;
return this.get(this.urlUser() + cmd);
}
protected get(cmd: string) {
//console.log(cmd)
return this._http.get(cmd);
}
So in my component, I'm passing in parameters to the data service to build the get request and make the call. Normally, in the component, I would just subscribe to that call and get the data back and do whatever with it. But I want to try and be a little more efficient in my code since I'm simply changing one parameter and calling the same function again. I know I could do a pipe and mergeMap but it didn't seem like I could access the first return using that method. Any suggestions/ideas?