Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also cancel remaining promises #4

Closed
fregante opened this issue May 4, 2021 · 6 comments · Fixed by #5
Closed

Also cancel remaining promises #4

fregante opened this issue May 4, 2021 · 6 comments · Fixed by #5

Comments

@fregante
Copy link

fregante commented May 4, 2021

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?

@sindresorhus
Copy link
Owner

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?

@fregante
Copy link
Author

fregante commented May 4, 2021

😁 sindresorhus/p-cancelable#29

@fregante
Copy link
Author

fregante commented May 4, 2021

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}),
])

@fregante
Copy link
Author

fregante commented May 4, 2021

Or

new pRace(signal => [
	fetch('/api', {signal}),
	setTimeout(10, {signal}),
])

@fregante
Copy link
Author

fregante commented May 4, 2021

Also shortcuttable to:

new pRace([
	[fetch, '/api'],
	[setTimeout, 10],
])

But this has a few drawbacks and some errors would be silent

@sindresorhus
Copy link
Owner

new pRace(signal => [
fetch('/api', {signal}),
setTimeout(10, {signal}),
])

I like this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants