rxios
rxios copied to clipboard
Support for request cancellation
Hello!
Thank you for this great library!
One of the greatest things about RxJS observables is that they are cancellable, this is especially important when it comes to network requests. So you will definitely want to terminate the pending network request, when it's result is no longer needed by the application (see switchMap). By briefly looking at the code I can't see the logic related to request cancelling, however, axios supports this. I would suggest to implement this critical feature.
axios-observable
also has this feature.
Thanks for the suggestion @slavafomin!
There's something I'd appreciate your input on, though:
I'm thinking that unsubscribing from the observables could also trigger the request cancellation in the background, somewhat similar to what axios-observable
is doing, and the actual request cancellation would then be hidden to the user.
Does this make sense, or would it be better to provide with an unsubscribe()
method that only unsubscribes and a cancel()
method that only cancels the request?
@davguij I believe that unsubscribing from observable should automatically free all associated resources, including cancelling the HTTP request in progress.