Skip to content
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

Merged
merged 5 commits into from
Aug 23, 2021
Merged

Conversation

ShaMan123
Copy link
Contributor

This is very useful and saves repetitive on off logic for calling an event once and it aligns Observable with node's EventEmitter

function _once(eventName, handler) {
var _handler = function () {
handler();
this.off(eventName, _handler);
Copy link
Member

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.

Copy link
Contributor Author

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?

@asturur
Copy link
Member

asturur commented Aug 23, 2021

This is good.

asturur
asturur previously approved these changes Aug 23, 2021
@asturur asturur dismissed their stale review August 23, 2021 14:40

ooppsss binding

@asturur
Copy link
Member

asturur commented Aug 23, 2021

i ll fix the semicolon and merge

@asturur asturur merged commit f5a98c1 into fabricjs:master Aug 23, 2021
@asturur asturur mentioned this pull request Aug 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants