Proposal AbortSignal.prototype.filter(compare) #1280
Labels
addition/proposal
New features or enhancements
needs implementer interest
Moving the issue forward requires implementers to express interest
topic: aborting
AbortController and AbortSignal
What problem are you trying to solve?
There is now an
AbortSignal.any([a, b, c])
that makes it possible to combine multiple signals, but there is currently no way to split a an AbortSignal. I therefore propose the instance methodAbortSignal.prototype.filter(compare)
, which would return a newAbortSignal
that only triggers if the reason matches some condition. For example:The above example creates a signal that will only trigger if the reason matches that of
AbortSignal.timeout(ms)
. If the reason doesn't match, then the returned signal will never trigger (since abort signals only ever trigger once).What solutions exist today?
It is fairly easy to implement this today as a separate function (to not pollute the prototype):
How would you solve it?
The above function could be placed on the AbortSignal prototype:
Anything else?
No response
The text was updated successfully, but these errors were encountered: