pjax icon indicating copy to clipboard operation
pjax copied to clipboard

Switch to Promises instead of callbacks

Open BehindTheMath opened this issue 6 years ago • 5 comments

Along with #109, we should consider switching to use Promises instead of callbacks. Most environments support it by now, and we can use a polyfill for those that don't.

BehindTheMath avatar Jun 18 '18 02:06 BehindTheMath

Promises will make cancelling the XHRs more complicated, since currently, native Promises cannot be canceled.

BehindTheMath avatar Mar 10 '19 18:03 BehindTheMath

What do you mean ? you can "cancel" a Promise with reject.

kiuKisas avatar Feb 19 '21 10:02 kiuKisas

You can reject a Promise, but you cannot abort the fetch request without AbortControllers, which is a newer API, and is not supported by IE.

BehindTheMath avatar Feb 19 '21 19:02 BehindTheMath

@BehindTheMath What about this? https://www.npmjs.com/package/abortcontroller-polyfill

imannms avatar Mar 27 '21 17:03 imannms

This "polyfill" doesn't actually close the connection when the request is aborted

BehindTheMath avatar Mar 31 '21 02:03 BehindTheMath