rxios icon indicating copy to clipboard operation
rxios copied to clipboard

Support for request cancellation

Open slavafomin opened this issue 4 years ago • 2 comments

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.

slavafomin avatar Aug 24 '20 18:08 slavafomin

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 avatar Aug 31 '20 11:08 davguij

@davguij I believe that unsubscribing from observable should automatically free all associated resources, including cancelling the HTTP request in progress.

slavafomin avatar Aug 31 '20 12:08 slavafomin