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

Allow unbind for eve.once #22

Open
trokster opened this issue May 26, 2014 · 0 comments
Open

Allow unbind for eve.once #22

trokster opened this issue May 26, 2014 · 0 comments

Comments

@trokster
Copy link

Couldn't find a clean way to do it so my approach is to pass in a third variable ( array or pointer ) then modify eve.once to assign f2 to that variable, so i can unsub with eve.off("evt", f2).

eve.once = function (name, f, unbinder) {
var f2 = function () {
eve.unbind(name, f2);
return f.apply(this, arguments);
};
if(unbinder) unbinder.push(f2);
return eve.on(name, f2);
};

It's absolutely ugly but does the job for now. Does anyone have a cleaner way to implement ?

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

No branches or pull requests

1 participant