I would like to delete everything that is in an Observable. So far I have done this :
This is in the service :
deleteAllHistory(history:History[]){
return forkJoin(
...history.map(hist => this.http.delete(this.apiURL '/' hist.id)
))
}
However this implies that if I have 500 elements in my Observable, I would be doing 500 http calls which in a performance point of view is not reliable.
Could you tell me if there is an easier way to delete all the entries in my Observable ?
Thank you for your time !
CodePudding user response:
Sounds more like a job for the backend. What you have there? Backend should have a separate endpoint for delete all
or take some parameters on the current endpoint to do so.
CodePudding user response:
whenever you don't need to using an observable that you have subscribed to it, easily you can unsubscribe it. About Http requests, they will cancel. But be sure about side effects of you Api call on your backend. For Example maybe they don't care about your cancellation.