-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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 Events#listenToOnce #2049
Add Events#listenToOnce #2049
Conversation
I'd prefer |
Using 'once' in the method name is more consistent and shorter. |
Here we go again with a thread about naming, but I'd prefer |
Fair enough. I like |
I still kinda want to keep the |
Have to agree with you. |
👍 |
+1 |
|
👍 on this (or some other way to easily clean up |
|
It needs the |
+1 listenToOnce! |
Rebased this one, so it can be applied cleanly to the current tree. |
@jashkenas - any opinion on this one? It does make the |
Fun implementation and nice API symmetry, but I'm a little concerned if anyone will actually find it useful. Would y'all use this? |
@jashkenas yes -- with |
I have not yet found occation for "once" events. A chained interaction perhaps where the second part depends on first, like choosing item from popup menu? |
I have
a |
Found myself needing this today: this.listenToOnce(this.filters, "change", function() {
this.filters.add(new Filter.Model());
}); I don't want to add a new filter every single time one has changed, I only ever add one once. |
@jashkenas I'm going to use this like that: this.listenToOnce(this.model, signedEvent, function() {
// do stuff;
}); 👍 |
As per discussion in #2045, I implemented
oneTimeListenTo
, an inversion-of-control version ofonce
. @caseywebdev and @tgriesser voted for the namelistenToOnce
, but I went withoneTimeListenTo
as it sounds clearer to me, but its up for discussion. If you guys likelistenToOnce
or some other name, I can change it.Edit:
Changed the name from
oneTimeListenTo
toonceListenTo
. Its still up for discussion, though.Edit:
Changed to
listenToOnce
as per the comments.