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

Cleanup addEventListener #16

Merged
merged 5 commits into from
Apr 27, 2024

Conversation

abdel-17
Copy link
Collaborator

The overloads for addEventListener define the event parameter as a string, but the implementation define it as string | string[].

This PR removes the unnecessary code needed to support string[].

Copy link

changeset-bot bot commented Apr 25, 2024

🦋 Changeset detected

Latest commit: 5e9f3cd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
runed Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Apr 25, 2024

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
runed ✅ Ready (View Log) Visit Preview 5e9f3cd

@huntabyte
Copy link
Member

We should be able to support an array of events, no? For example, multiple events with the same handler.

@abdel-17
Copy link
Collaborator Author

You can do that and modify the overloads instead, though I'd just leave it like this.

@abdel-17
Copy link
Collaborator Author

Also, we would need to modify the types for useEventListener as well.

@huntabyte
Copy link
Member

I only ask this because we're doing this exact thing in Bits (handling a list of events with a single handler) which is nice. I do wonder how often it is used and if it's worth adding, thoughts @TGlide @AdrianGonz97?

@TGlide
Copy link
Member

TGlide commented Apr 26, 2024

I only ask this because we're doing this exact thing in Bits (handling a list of events with a single handler) which is nice. I do wonder how often it is used and if it's worth adding, thoughts @TGlide @AdrianGonz97?

I can see the use case for sure, not the most common thing, but definitely useful

@abdel-17
Copy link
Collaborator Author

abdel-17 commented Apr 26, 2024

I restored the old behavior and fixed the overloads to match it. Though, I will say, autocomplete doesn't really work when you pass an array with two or more values. Not a big deal, just something worth mentioning in case there's a way to fix it.

Edit: nevermind autocomplete works. Was probably TS server being weird.

@TGlide TGlide merged commit 22de8ae into svecosystem:main Apr 27, 2024
3 checks passed
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.

3 participants