Skip to content
This repository has been archived by the owner on Sep 26, 2022. It is now read-only.

(Draft) Feat: ability to abort requests #198

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

dfidalg0
Copy link

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 🤓

For those willing to implement the iOS part, the main ideia is

  • Pick the signal parameter ({ 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 __abortRequest that receives a { abortCode: integer } and interrupts the corresponding socket.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant