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

[✨] Remove Event Listener after event is invoked once #3464

Closed
theonlychase opened this issue Mar 21, 2023 · 3 comments
Closed

[✨] Remove Event Listener after event is invoked once #3464

theonlychase opened this issue Mar 21, 2023 · 3 comments
Labels
STATUS-2: missing info Incomplete issue/pr template or missing important information STATUS-3: no response The issue / PR creator has not responded for a while TYPE: enhancement New feature or request

Comments

@theonlychase
Copy link

Is your feature request related to a problem?

The problem I am having is not being able to remove an event listener after it is invoked once, either by setting it on the element itself, or by creating an event using the useOn hook.

Describe the solution you'd like

The ability to set any of the event listener options, such as { once: true }. The event listener would automatically be removed after being invoked once.

Describe alternatives you've considered

As an example, I am currently using state to handle a window onScroll event that I only want triggered once based on the scroll position.

Additional context

Another option is using an intersection observer. I understand there is useVisibleTask?(), which can use an observer under the hood, but there is no way to set any of the Intersection Observer Options, or see the properties on the entry itself, such as the intersectionRatio. If the component/element is above the fold on page load, that Javascript gets loaded right away, which I want to avoid.

@theonlychase theonlychase added TYPE: enhancement New feature or request STATUS-1: needs triage New issue which needs to be triaged labels Mar 21, 2023
@manucorporat manucorporat added this to the BACKLOG: Post v1.0 milestone Mar 21, 2023
@PatrickJS
Copy link
Member

you can add an attribute to the element and check the value

@gioboa
Copy link
Member

gioboa commented Oct 14, 2024

@theonlychase is it solved?

@gioboa gioboa added the STATUS-3: no response The issue / PR creator has not responded for a while label Oct 14, 2024
@github-actions github-actions bot removed the STATUS-1: needs triage New issue which needs to be triaged label Oct 14, 2024
@gioboa gioboa added the STATUS-2: missing info Incomplete issue/pr template or missing important information label Oct 14, 2024
Copy link
Contributor

Hello @theonlychase. Please provide the missing information requested above.
Issues marked with STATUS-2: missing info will be automatically closed if they have no activity within 14 days.
Thanks 🙏

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
STATUS-2: missing info Incomplete issue/pr template or missing important information STATUS-3: no response The issue / PR creator has not responded for a while TYPE: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants