Based on the parameters of the function I want to build the forkJoin() method.
For example:
- if parameter1 is empty => don't put a http request for it inside the forkJoin()
- if parameter2 is empty => don't put a http request for it inside the forkJoin()
Code:
getAllByIds(parameter1: any, parameter2: any) {
let itemList = new Array();
return Observable.forkJoin(
this.http.get('rest/fillin/ids/' + parameter1) // don't put this request for parameter1 if it is empty
.map((res: Response) => res.json()),
this.http.get('rest/textitem/ids/' + parameter2) // don't put this request for parameter2 if it is empty
.map((res:Response) => res.json())
).map(
data => {
itemList.push(data[0]);
itemList.push(data[1]);
return itemList;
}
);
}
So, is it possible to build up the forkJoin() like this?