GeppettoJS / backbone.geppetto

Bring your Backbone applications to life with an event-driven Command framework.
http://geppettojs.github.com/backbone.geppetto/
MIT License
203 stars 28 forks source link

Dispatch to parents #62

Closed mmikeyy closed 10 years ago

mmikeyy commented 10 years ago

Ok, here is the bubbling dispatchToParents method, with tests. Took the liberty to add a little feature: stopPropagation set to true in payload by any ancestor stops further bubbling. If one ancestor needs to catch the event and do the job, why bother its ancestors (and waste time) with useless triggers?

Cool feature is that since the same object is passed along as payload, data can easily be sent back to issuer or shared between ancestors. Feel free to improve or to let me know if I missed something.

geekdave commented 10 years ago

I think stopPropagation might be a bit misleading since it's a well known method of events

Agreed.

Suppose we eventually want to stop propagation in a context where it has nothing to do with bubbling.

Agreed.

The problem with verb + complement is that, to me, it always communicates as a function.

Agreed.

How about shouldPropagate ? It communicates intention, not just status.

@mmikeyy thanks for leading this. Would you mind updating the README with documentation and examples of this as well?

creynders commented 10 years ago

I like the idea of shouldPropagate, but it's definitely out of left field, and still is a verb+complement, i.e. I'd still have the inclination to do event.shouldPropagate()

mmikeyy commented 10 years ago

Changes committed for propagationDisabled. OK for documentation. BTW... I can't seem to be able to find our conversation where the final ok was given for propagationDisabled... . Where has it gone? (got it in my emails but it seems to be absent up here and in previous commits; it was there before!). No big deal, just curious...

geekdave commented 10 years ago

Check the "Files changed" tab - could be an inline comment

On Fri, Sep 5, 2014 at 12:23 PM, mmikeyy notifications@github.com wrote:

Changes committed for propagationDisabled. OK for documentation. BTW... I can't seem to be able to find our conversation where the final ok was given for propagationDisabled... . Where has it gone? (got it in my emails but it seems to be absent up here and in previous commits; it was there before!). No big deal, just curious...

Reply to this email directly or view it on GitHub https://github.com/ModelN/backbone.geppetto/pull/62#issuecomment-54662613 .