-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Add third parameter to once event handler #8875
Changes from 5 commits
6d7277a
64bd5cb
c73f64f
b0d3555
6becd9a
e5492f7
c373a75
4d5172f
3e0cc73
ffe7d5d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,7 +89,7 @@ export class Evented { | |
* @param {Function} listener The function to be called when the event is fired the first time. | ||
* @returns {Object} `this` | ||
*/ | ||
once(type: string, listener: Listener) { | ||
once(type: *, listener: Listener) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should remain There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kkaefer flow fails without There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, flow seems to have trouble matching a string to a string literal :/ |
||
this._oneTimeListeners = this._oneTimeListeners || {}; | ||
_addEventListener(type, listener, this._oneTimeListeners); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function uses
Evented#once
to add listeners, which means that the event listener will be added tothis._oneTimeListeners
. Once the event is fired, it will be removed from that list. However, it will not be removed from this._delegatedListeners`, which means that handlers are going to accumulate in this array causing memory growth.