-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
events: Loop forwards to find listener in removeListener function #21635
Comments
Can you explain why you think so? |
To remove a listener we need to "find" it. Like |
At this point, I'd say the easier thing to do is to update the documentation rather than making a semver-major change. |
Fixes: #21635 PR-URL: #23762 Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
Fixes: #21635 PR-URL: #23762 Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
Fixes: #21635 PR-URL: #23762 Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
Fixes: #21635 PR-URL: #23762 Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
Fixes: #21635 PR-URL: #23762 Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
Fixes: #21635 PR-URL: #23762 Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
removeListener()
inevents
module loop backwards to find listener from array. Consider the following code:The output shows that for multiple same listeners, the last added one will be the first to remove (LIFO). I think maybe a "FIFO" logic is better for this case. And I find the commit on 5 Mar 2013 which implements "loop backwards" logic.
3e64b56#diff-71dcd327d0ca067b490b22d677f81966
The commit message shows this logic optimize
removeAllListeners()
.But it did effect this specific case. MayberemoveAllListeners()
should keep "LIFO" logic and the backward loop optimizing, andremoveListener()
could use a forward loop.The text was updated successfully, but these errors were encountered: