Also cancel remaining promises
fregante opened this issue · comments
Federico Brigante commented
It kind of irks me that the default for races is to just let everything continue even when the race ended.
What do you think about also calling .cancel
to the promises that are running?
Sindre Sorhus commented
I'm not sure I want to continue adding support for the p-cancelable
way. It seems the ecosystem is moving to use AbortController
. Is there any way we could support AbortController
for this?
Federico Brigante commented
Federico Brigante commented
I suppose that the 2 could actually just be combined here, without extending p-cancelable
new pRace([
signal => fetch('/api', {signal}),
signal => setTimeout(10, {signal}),
])
Federico Brigante commented
Or
new pRace(signal => [
fetch('/api', {signal}),
setTimeout(10, {signal}),
])
Federico Brigante commented
Also shortcuttable to:
new pRace([
[fetch, '/api'],
[setTimeout, 10],
])
But this has a few drawbacks and some errors would be silent
Sindre Sorhus commented
new pRace(signal => [
fetch('/api', {signal}),
setTimeout(10, {signal}),
])
I like this one.