Isolation of components - always required?

Hey Ben :smile:

I think actions bubbling to components would make sense - it might have some edge cases that make it hard though. For example, what if you have a component that renders another controller - the action should generally bubble from the template’s controller to the route, so in this case it might skip the parent controller.

Bubbling downwards would also be interesting - not sure how you would implement it though.

Altogether though, I’m not entirely convinced that in practice it makes that much difference - and there’s the risk you’d end up reimplementing bindings with these events in effect (i.e. watching for the event on both sides and then setting a property).

One thing I’ve been thinking of since I started this thread is explicitly specifying what’s accessible - I haven’t thought about this entirely so this is not a real API proposal, but something like:

App.ParentComponent = Em.Component.extend
  childrenCanBindTo: ['prop1', 'prop2']

App.ParentComponent = Em.Component.extend
  parentsCanBindTo: ['prop1', 'prop2']

Or something like that - so that you can explicitly specify and enforce dependencies, much like you do when you put components in a template anyway.

Regardless of what happens with bindings, I think that actions bubbling to parent components should happen if it’s possible to resolve the ambiguousness of how that works when switching controller scope in a template.

1 Like