Articles

Salesforce Lightning Components and Its Best Practises

by Udit Handa CEO - Cynoteck Technology Solutions
The Salesforce Lightning Component Framework is a UI framework for building dynamic Salesforce online apps for desktop and mobile platforms. A Salesforce developer creates lightning elements, while a Salesforce administrator puts them together and creates a lightning page. A record's detail page, web page, or SFDC page will be a Salesforce lightning page. For the best implementation of the lightning component, it is important to have the right salesforce maintainence and support.

Why is the lightning component Framework used?

  • The Lightning Component Framework gives you the tools you need to build apps quickly.
  • There's no need to start at the beginning.
  • When a user clicks a button, scrolls, and so on, the Lightning component Framework tacks browser vents.
  • We may create and distribute our own elements with other Salesforce customers.
  • Data was exchanged between the server and the client via JSON.
  • Salesforce Lightning Component Framework is compatible with the most recent browser technology, including HTML5, CSS3, and touch events.


Preventing Server Trips
Avoiding server trips is the most obvious way to enhance Lightning Component Performance. Let's say you need to know the queue Id to be allocated as the owner in Case and a custom setting information to deduce the Lightning Component's behavior. There are two methods to accomplish this: call Apex Controller twice or return combined Apex results in a single call and process JSON in the Lightning Product's client-side controller.

Take use of Lightning Data Service.
Lightning Data Service is the Lightning Component's version of Standard Controllers.
For your Lightning Component, you don't need to write Apex, Test classes. However, rather than just stating that we don't need to create Apex, Lightning Data Service requires more recognition. The capability of Data Service to use a shared cache is another critical feature. This Trailhead module has more information on Lightning Data Service.

Unbound Expressions are used
In Lightning Components, there are two ways to bind variables. Bi-directional binding is indicated by the! symbol, such as !v.var1. If the value of var1 changes, the Lightning component is alerted, and the value is changed. As you might expect, the Lightning component needs to use event listeners to keep track of changes in the background. If you don't need to update Lightning components because the value isn't updating, you can save time by using # instead of!. #v.var1 would be the syntax.

Application event usage should be limited
There are two types of events: app and component events, as we all know. Application events are quite strong and provide a lot more flexibility for communicating between any software components. However, we need to exercise extreme caution when using the Application event. Because the Application event is broadcasted to all components at the same time, it may be excessive for some elements. I recommend reading this post, which outlines how component communication takes place and the best techniques for doing so.

Javascript Libraries Should Be Used Sparingly
This is the ideal opportunity to brush up on your Javascript skills. There was a time when just a few libraries existed, such as JQuery and underscoreJs. However, with the ever technology, new libraries and new versions of existing libraries appear every second. With the active release of EcmaScript, vanilla Javascript has also gotten more powerful. By mixing Vanilla Javascript and the Aura framework, you may be capable of accomplishing the majority of your goals. For Lightning Component development, $A.util contains a lot of handy functions.

Components of Lightning's Base

Instead of recreating the wheel or using third-party Lightning Components, start with the basics. If you already have a Base component, developing a custom component and then implementing Salesforce Lightning Design System makes no sense. Lightning Design System, enhanced performance with reduced footprints, and standard procedures are all included in the base component. More information about the smallest parts can be found here.

Apex Web Components
Instead of making a strong server trip, the Lightning component displays a saved result in this technique. The lightning component will perform a parallel call to the server (Apex), and if the stored result is outdated, it will cache and refresh the lightning component. This is particularly beneficial for devices with slow internet connections. You can easily relate to it if you use Facebook or Google News. When we launch these apps, it displays the last feed and, if new feeds are available, it provides us the choice to refresh the view manually and automatically. All you have to do is use this code action to mark the action as storable on the client-side controller of the Lightning component. setStorable(). This blog post delves into the details of how storable actions function.

Sponsor Ads


About Udit Handa Junior   CEO - Cynoteck Technology Solutions

1 connections, 0 recommendations, 19 honor points.
Joined APSense since, March 23rd, 2022, From Saint Paul, United States.

Created on May 11th 2022 05:39. Viewed 242 times.

Comments

No comment, be the first to comment.
Please sign in before you comment.