-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
It gets annoying to compose with other things if it uses a different aborting mechanism.
A common pattern in the web platform is to have a single AbortSignal passed in to a function, and have all async work within the function listen on that signal so that you can easily cancel the function. If this uses a bespoke mechanism for aborting, then instead of being able to do that for everything in your function you have to carve out a different (and more annoying) mechanism for this specific function: compare
let task = await normalTask({ signal });
let token = await governor.acquire({ signal });vs
let task = await normalTask({ signal });
let { abort, tokenPromise } = governor.acquireAbortable();
signal.addEventListener('abort', abort);
let token = await tokenPromise;Also you'd better hope that normalTask doesn't ever do any async work which isn't guarded by the signal, because if it does then you also need to remember to add signal.throwIfAborted() or else it doesn't actually work.
Metadata
Metadata
Assignees
Labels
No labels