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

Don't return AbortController #32

Merged
merged 1 commit into from
Aug 31, 2022
Merged

Don't return AbortController #32

merged 1 commit into from
Aug 31, 2022

Conversation

fregante
Copy link
Owner

@fregante fregante commented Aug 3, 2022

I think that accepting a signal and returning a new controller is a bit confusing. I think it should match native events more closely: just accept a signal.

It's more verbose, but it pushes people to use and reuse signals instead:

- const controller = delegate(…);
+ const controller = new AbortController()
+ delegate(…, {signal: controller.signal})
  controller.abort()
- const controller1 = delegate(…);
- const controller2 = delegate(…);
- controller1.abort()
- controller2.abort()
+ const controller = new AbortController()
+ delegate(…, {signal: controller.signal})
+ delegate(…, {signal: controller.signal})
+ controller.abort()

@stof
Copy link
Contributor

stof commented Aug 30, 2022

I totally agree about that. It is weird to return a controller. No signal-based native API does that.

So 👍 for this change

@fregante fregante changed the title Drop internal controller Don't return AbortController Aug 31, 2022
@fregante fregante merged commit 8a6c2f2 into main Aug 31, 2022
@fregante fregante deleted the drop-internal-controller branch August 31, 2022 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants