[Bug 28455] New: Add a method to add a one-time event listener

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug 28455] New: Add a method to add a one-time event listener

Bugzilla from bugzilla@jessica.w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=28455

            Bug ID: 28455
           Summary: Add a method to add a one-time event listener
           Product: WebAppsWG
           Version: unspecified
          Hardware: Other
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DOM
          Assignee: [hidden email]
          Reporter: [hidden email]
        QA Contact: [hidden email]
                CC: [hidden email], [hidden email]

It seems to be a common pattern to have code like:

element.addEventListener("click", function onClick(event) {
  element.removeEventListener("click", onClick);
  ...
});

jQuery has method ".one()" to simplify this pattern.

I think it would be great if DOM directly includes a method for this in
EventTarget. Probably this method could be:

void listenForNextEvent(DOMString type, EventListener? callback, optional
boolean capture = false);

--
You are receiving this mail because:
You are on the CC list for the bug.

Reply | Threaded
Open this post in threaded view
|

[Bug 28455] Add a method to add a one-time event listener

Bugzilla from bugzilla@jessica.w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=28455

Anne <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |WONTFIX

--- Comment #3 from Anne <[hidden email]> ---
Closing this for now. If we do this we should have a new better event API in
general, that addresses a number of concerns.
https://gist.github.com/annevk/4475457 has a sketch of such a thing, if you're
interested.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug 28455] Add a method to add a one-time event listener

Bugzilla from bugzilla@jessica.w3.org
In reply to this post by Bugzilla from bugzilla@jessica.w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=28455

Anne <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|WONTFIX                     |MOVED

--- Comment #4 from Anne <[hidden email]> ---
This is now https://github.com/whatwg/dom/pull/207. I found a way to do this
now addEventListener() takes options. Would love your feedback.

--
You are receiving this mail because:
You are on the CC list for the bug.