Code By Code – Lightning Framework – Chapter 18 – Lightning Communication

Code By Code – Lightning Framework – Chapter 18 – Lightning Communication

Topics for this chapter:

  • All different ways to communicate between components

There are many ways to communicate between components. We have already learned a few of them from previous chapters. Let’s have a look at all possible communication methods.

1. Attribute and Expressions – While creating child components, you can pass attribute values using expressions. Bound expression creates 2-way data binding, which helps in communicating between parent and child component. Below is the code snippet from “CarDetails” component which has a child component AddCarExperience:

<c:AddCarExperience car="{!}" />

2. Component Event – As we read in detail in chapter 13, component events are a great way to communicate between components within the same hierarchy.

3. Aura Methods – From chapter 15, we have learned about another way of communication between aura components.

4. Application Events – From the previous chapter in this guide, we have learned about application events, which help in communicating between two different components.

5. Shared JavaScript resources – You can use shared JavaScript resources to share data between 2 different components. Singleton pattern is the best way to do this.

Manish Choudhari

I am a certified Salesforce Application & System Architect and Developer working on Salesforce Technology since 2014. Currently, I have 14 Salesforce certifications along with OCPJP (Oracle Certified Profession JavaSE6 Programmer) working in Hyderabad as a Technical Engineer. Writing technical blogs, learning new technologies and frameworks and sharing knowledge is my hobby.

This Post Has 2 Comments

  1. Hi Manish,

    Could you please specify what is the singleton pattern. Can we really send data between two components without events or aura:method ?

Leave a Reply

Close Menu