Add a convenient way to remove a listener inside itself.
See original GitHub issueIt would be nice to have a method to remove a listener inside itself.
This might be possible by overloading all registerXyzListener()
with a method that accepts a BiConsumer
that consumes both the event and the listener manager for this listener.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
JavaScript: remove an event listener from within that listener?
You can pass the once option to have a listener act only once, then remove itself.
Read more >JavaScript | removeEventListener() method with examples
The removeEventListener() is an inbuilt function in JavaScript which removes an event handler from an element for a attached event.for ...
Read more >EventTarget.removeEventListener() - Web APIs | MDN
The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.
Read more >Four ways of listening to DOM events in Angular (Part 3
Unlike Event Binding or @HostListener methods, with Renderer2.listen , you can manage complex event listeners by adding and removing them on specific conditions ......
Read more >Events | Maps JavaScript API - Google Developers
Removing Event Listeners ... To remove a specific event listener, it must have been assigned to a variable. You can then call removeListener()...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Oops, you are right ofc. But the “idea” keeps the same:
Ah, right. Actually also the array variant should work without race condition and be marginally cheaper due to no need for volatile field and compare and swap algorithm as it is written before the other thread will read it and not modified.