I have a set of 6 http get requests which I have to make irrespective of their sequence on a button click.I am using forkJoin
for that purpose
<button click="getData()">Get Data</button>
getData(){
const ids = [1,2,3,4,5,6];
const obs = ids.map(id => this.http.get('<my url>/' + id)
forkJoin(...obs).subscribe(res => console.log(res));
}
If a user clicks on the button multiple time, is there a way I could cancel previous uncompleted requests and only make new fresh calls to the backend ?
I did some research and understood switchMap operator helps in cancelling requests but I am not sure how I would be using it here.
Please help