coldfusion
coldfusion

Reputation: 43

emberjs component communication

I have some trouble with component communication. Lets say I have 3 nested components.

Parent {{component-a}} -> which has child {{component-b}} -> which has child {{component-c}}.

How can I access component-c directly from component-a, if component-c is not rendered. Is this even possible. Thank you

Upvotes: 1

Views: 112

Answers (2)

NullVoxPopuli
NullVoxPopuli

Reputation: 65103

You'll generally want to use a service for communication across different trees of components or for 'sending data up from a child component'

Services are very easy to test.

Using data-down-actions-up would also work, but beyond a couple layers is known as prop drilling. Prop drilling makes components hard to maintain due to over-inter-connectness

Hope this helps!

Upvotes: 1

lpinto.eu
lpinto.eu

Reputation: 2127

Ember uses a data down action up pattern. This means that if you want to send data from a component to its child you pass it by a parameter, but if you want the opposite direction you should send an action with the data. And when you have 3 components you pass by the one in the middle and this one will keep on relaying the information.

You can find more information here

Upvotes: 3

Related Questions