http
http copied to clipboard
(Draft) Feat: ability to abort requests
This is basically the same as #193, but as a draft PR as suggested by @thomasvidas.
The proposal is to have a request abort API that behaves similar to the standard fetch API.
const controller = new AbortController();
Http.request({
url: 'some.api.com',
method: 'get',
signal: controller.signal
}).then(...);
...
if (requestShouldBeAborted) {
controller.abort();
}
Currently, the implementation supports only web and Android, since I don't have a Macbook and don't know how to properly implement this in Swift. So, any help is welcome :nerd_face:
For those willing to implement the iOS part, the main ideia is
- Pick the
signalparameter({ aborted: boolean; abortCode: integer; })passed down to the plugin call and track the corresponding socket (requests that don't have a signal shouldn't be tracked). - Implement a plugin method called
__abortRequestthat receives a{ abortCode: integer }and interrupts the corresponding socket.