You are currently viewing Deep Diving Into Building Lightning Components

Deep Diving Into Building Lightning Components

Sharing is caring!

In this blog post, we find out more about Salesforce Lightning Components and dig a little bit deeper. It is always an added advantage if you have some extra knowledge. So let’s dive in and learn more about Lightning Components.

Lightning components are loosely coupled app modules. They adopt a plug-n-play approach for the developers. So have you ever thought, how these loosely coupled components interact with each other? How they work together? Let’s have a look.

ALL ABOUT LIGHTNING EVENTS:
The question is what are lightning events and how they work.

WHAT: Lightning events are used to interact with lightning components. Components declare the events they send out along with the components they can handle.

HOW THEY WORK: Events are fired via JS Controller actions that are triggered by the user using the interface.

TAG: It is represented by using the following tag:

aura: event

TYPES Of LIGHTNING EVENTS:

  • System Events
  • Browser Events
  • Application Events
  • Component Events
  • Navigation Events

Let’s understand them one by one

System Events: Lightning Component Framework has a set of events which are used to notify components that something important has been done by the framework.
Example:
init – It is sent to components when they are initially loaded
re-render – It helps the system to understand that a component needs to re-render after an event

Browser Events: They are not particular to the lightning framework. They are browser notifications that are fired whenever the user interacts with an element.
Example:
<th onclick=”{!c.sortGrid}”>Header</th>

Application Events: It is useful when one needs to have integration between lightning components that live on same and different namespaces. They work like a publish-subscribe model, i.e., one lightning component fires the event, and all lightning components that have subscribed to the event gets notified. Their propagation preserves the framework’s default handling behavior. It controls the behavior of handler and helps them to interact with the event.
Example:
aura:registerEvent

Component Events: It is useful when one wants to pass information from Parent components to child components. It is fired from an instance of components. It can be handled by the component that fired the event or any parent in the hierarchy. They interact with the event and control the behavior of the event.
Example:
<!--c:ceEvent>
<aura:event type="COMPONENT">
<aura:attribute name="text" type="String"/>
</aura:event>

Navigation Events: It enables components interaction within Lightning Interaction and Salesforce1.
Example:
force:navigateToURL (It helps to navigate to specify URL)
force:createRecord
force:editRecord

WHAT IS LIGHTNING BASE COMPONENTS?
They are the basic building blocks which are accessible through codes. They build up a user interface for Lightning Experience, Communities, and Salesforce1. They handle HTML and CSS. Now it is not necessary anymore to use static resources always. One can simply use pre-defined components as well.

Example:
lightning:button
lightning:buttonIcon

WHAT IS LIGHTING DATA SERVICE???
One can easily load, create, edit and delete a record in the component without using any Apex code. It handles field level security and sharing rules for you. It resembles “Standard Controller” in visualforce pages. It includes the following:


force:recordData

It doesn’t render any UI but put a standard controller for visualforce pages inside lightning components. It provides the ability to create, read, update and delete records in components. It uses following methods:

  • getNewRecord
  • reloadRecord
  • saveRecord
  • deleteRecord

Shared Record Cache: There is no need to search the server every time if they make any changes.

Offline Support (Draft): It is planned for future and not yet developed fully. According to this, It means that we will be having a lighting page with all lightning components working with record data in the cache. It will be handy if one doesn’t have an internet connection. Isn’t it sound exciting? We can access our data independent of internet connection. COOL!!.. Let’s wait for this super-exciting feature.

Benefits of dynamically creating components:

  • Flexible:
    No doubt lightning components are flexible, i.e., they can be changed depending on the requirements.
  • Reusability:
    LC’s are reusable since they have a modular design. Components can be reused for different solutions.
  • Room for Growth:
    Dynamically created components can be extracted. It is just like the cherry on the cake. LC’s provide us the components which always have that extension feature. They are not limited to any one thing.

Never confine yourself with limited knowledge. Always try to learn new things and grasp them quickly. It is always a necessity to keep pace with the enhancements happening in technology on a daily basis. Thus, there is always a lot more to learn and explore.

 

Till Then, Happy Lightning!!

 

Suraj

Suraj Tripathi

Salesforce Consultant | Solutions Engineering Head
"Suraj Tripathi, a certified Salesforce Principal Consultant of repute, is a wonderful mentor and leader. A certified Salesforce Architect and a 7x Salesforce Certified Platform Application Developer by passion and profession, Suraj has rich experience in languages such as Aura, HTML, Angular, Bootstrap, APEX, and JavaScript. With more than five years of expertise in Salesforce Development, Suraj has worked on more than 50+ projects out of which 20+ projects were related to Salesforce Integration, Writing Triggers, Batch classes, VisualForce pages, and Aura Components.

Hire the best Salesforce Development Company. Choose certified Salesforce Developers from Cloud Analogy now.

This Post Has 2 Comments

  1. Sheen

    Thank you for sharing excellent information. Your article is so cool. I am impressed by the details that you have shared with this article on Lightning Components.

    1. Cloudanalogycrm

      Hi Sheen, Appreciate your kind words. We are glad you like it.
      Thanks 🙂

Leave a Reply

× How can I help you?