-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
feat(Observable): once event handler #7317
Conversation
function _once(eventName, handler) { | ||
var _handler = function () { | ||
handler(); | ||
this.off(eventName, _handler); |
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.
I wonder how this work with hoisting.
We are referencing the function before we finish create it.
Is not a question about your code but more on javascript.
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.
I use it in my code....
What other option is there?
This is good. |
i ll fix the semicolon and merge |
This is very useful and saves repetitive
on
off
logic for calling an event once and it alignsObservable
with node'sEventEmitter