1

I want to use (some of) my own ember components in a nested way. Think

{{#form-helper data=model}}
  {{form-field datakey="name"}}
  {{form-field datakey="street}}
  {{form-field datakey="city}}
{{/form-helper}}

Generalized: I've got two components that are meant to work together in a nested way. The outer one provides some environment that is consumed by the inner one. http://alexspeller.com/simple-forms-with-ember/ has this explained in some more detail and uses the inner components parentView to access the outer context. Great.

Now, ember components are meant to fill in for web components as long as they aren't ready for prime time, but from what I understand web components are meant to be encapsulated. The only way to exchange information are data binding and events.

If this is correct and ember strives to replace its own components with web components, would this solution be future proof. Can I rely on ember delivering some kind of parentView access after the switch to real web components?

If not, what would be the right, the ember way to do this? A component outside and view helpers inside? Some usage of binding and events that I am currently unaware of?

I know I've got a solution for now, but I'm developing a solution that will be in use for quite a long time, so I want to avoid anything that's essentially deprecated at the time of writing my code.

jnfingerle
  • 713
  • 4
  • 16
  • Since View/Component.parentView is part of the public API, and I haven't heard anything about it being deprecated, I would say it's safe to assume that it is pretty future proof. – Mike Wilson Mar 20 '15 at 20:00
  • This is OK for 2.0. But, I think, "real" web components would rather be a topic for a 3.0. I know, we're in largely uncharted territory here, but I was hoping for some insight along the lines of (1) "you're right, this should be encapsulated and we will have to break this in the long run" or (2) "encapsulation for components will always be breakable, as long as you stay inside ember, even if the api might change". All with its due grain of salt, but with deeper insights than mine ;-) – jnfingerle Mar 23 '15 at 09:40
  • For future reference, I gave this question a try [on ember discuss](http://discuss.emberjs.com/t/is-accessing-a-components-parent-view-in-ember-future-proof/7604) as well. – jnfingerle Mar 23 '15 at 09:56

0 Answers0