-
Notifications
You must be signed in to change notification settings - Fork 534
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 support for this.once #185
Comments
easy way is to add a function wrapper called once in utils.js so then this.on('click', utils.once(myHandler)) Tal expressed interest in doing this |
I'm interested in why this isn't baked in. I totally respect the decision not to have it, but I'm just wondering what the reasoning is? Also, what are the pros and cons of, for example, using a |
I feel like |
The overhead of adding fully fledged this.once is we would need registry Having a withOnce mixin would be saying we don't want it baked into core. I @angustweets On Wed, Oct 16, 2013 at 2:03 PM, Tom Ashworth notifications@github.comwrote:
|
Intuitive because jQuery does it? Seems like a slightly gratuitous trigger/on/off is a really simple event API and I'd prefer to keep it at @angustweets On Wed, Oct 16, 2013 at 2:09 PM, Nicolas Gallagher <notifications@github.com
|
I see. Thanks for the explanation! |
Ok, I see – but just to be clear, I wasn't suggesting Flight ship with a |
Ah I see! Yes, I got the wrong end of the stick. Still I think utils.once(fn) could be a useful util in general - and we @angustweets On Wed, Oct 16, 2013 at 2:23 PM, Tom Ashworth notifications@github.comwrote:
|
i made a pull request to implement this feature into utils. it is similar to the lodash/underscore implementations. |
While I think that is good to have an utility like My proposal: https://gist.github.com/giuseppeg/7020843 |
@giuseppeg why does it need to? In fact isn't it cleaner to remove all handlers in one go at teardown? Moreover your solution is incomplete, we'd also need to add Let's try and keep our API simple. The following is intuitive and adds nothing to our core code base (other than a reusable util)...
|
@angus-c because it keeps listening for that event and handling it when we actually don't need it anymore. That said, I am fine with the util solution :) |
I think this fits in nicely with the "util" idea. It provides something that underscore or lodash provides without having to actually including the libraries. |
I think this can be closed, as it got added in #186. |
To use jQuery's
.once
method.The text was updated successfully, but these errors were encountered: