3 ms·
A comment on the description of listenTo on the Docs page: > Tell an object to listen to a particular event on an other object. The advantage of using this for
by eric-hu 14y ago
A comment on the description of listenTo on the Docs page:
> Tell an object to listen to a particular event on an other object. The advantage of using this form, intead of other.on(event, callback), is that listenTo allows the object to keep track of the events, and they can be removed all at once later on.
I had to read this a few times and the given example to see that the convenience comes from tracking events on the listening object side.
Using "object" and "other" for the object variable names makes it a little confusing. I didn't realize the bolded "object" meant the listener object, as opposed to the object being listened to.
- jashkenas 14y agoYes -- I struggled for a while with the wording of that. I've you've got a re-phrasing that would make it clearer, I'm all ears.
- eric-hu 14y agoThis explanation actually provides 2 examples, one before the description text and one after. The description refers to the example before: > listenTo object.listenTo(other, event, callback) I think changing the naming to be more specific and updating the description names could help out. listenTo observingObject.listenTo(actingObject, event, callback) One caveat is that this breaks consistency with the other examples in this section (i.e. object.once(...) object.trigger(...)).