How to cancel/abort all pending HTTP requests in angular 4+.
There is an unsubscribe
method to cancel HTTP Requests but how to cancel all pending requests all at once.
Especially while route change.
There is one thing I did
ngOnDestroy() {
this.subscription.unsubscribe();
}
but how to achieve this globally
Any Ideas?
If you don't want to manually unsubscribe all subscriptions, then you can do this:
Then you can use it as decorator in your component
but you still need to store subscriptions as component properties. And when you navigating out of component, AutoUnsubscribe function will occurs.