-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Greetings! thanks for really great and simple library, this is exactly how Promise Abort API should be implemented in my opinion! Simple, obvious and extremely useful!
I understand why we redefine AbortSignal and AbortController (because of abort(reason) lack, by the way - I think reason can be exposed also as signal.reason (in case of signal.aborted - like in https://github.com/getify/CAF#signalaborted-and-signalreason).
My question is about Fetch API from example. Why original signal can't be passed to Fetch API? Is it some interface incompatibility, or internal instanceof check? Even if it's impossible for some reason, IMHO example should explicitly explain why.
const promise = new AbortablePromise((resolve, reject, signal) => {
const url = `/`;
const controller = new AbortController();
fetch(url, { signal: controller.signal }).then(resolve, reject);
signal.onabort = controller.abort.bind(controller);
})
// --- Why not
const promise = new AbortablePromise((resolve, reject, signal) => {
fetch(url, { signal }).then(resolve, reject)
})
Metadata
Metadata
Assignees
Labels
No labels