How do Lightning Components interact with Salesforce?
Hi All,
Today one of my blog visitor asked me, how do Lightning Components interact with Salesforce? How does Lightning component get data from server? I thought to write an article on this, it might help you also to understand the architecture of Lightning Component Framework.
Below image will help you in understanding this.
- Whenever a Lightning Component or an App runs on browser of Mobile device, it first download all component resources(i.e. Styles, Scripts, Markup) on mobile device. They are contained in browser’s memory to support display and processing that is why we call it client-side.
- Now if you want to call a apex method from client side, you will fire an event on client side. This event will call a JavaScript method on client-side. This client-side method will make an HTTP requests to Salesforce to call apex method on server-side. Like you do in VisualForce using action function or other JavaScript.
- This HTTP request to call apex method will be asynchronous. Asynchronous means you will make the request and forget about it and the controller returns to the client. The processing will be done on server-side.
- In the meantime Salesforce processes the logic by executing some apex.
- Finally when it is done with processing and gets some resulted data or not, it makes a callback to the browser/client-side. The client response by invoking an associated JavaScript callback function which extract data passed back by apex methods. This data can be assigned to component attributes. Now display will be automatically refreshed.
Hope this will be helpful 🙂
February 10, 2016 at 11:04 am
[…] Source: How do Lightning Components interact with Salesforce? […]
LikeLike
February 10, 2016 at 11:09 pm
Nice post Balkishan, Can you please share link of whitepaper or documentation as well ?
LikeLiked by 1 person
February 11, 2016 at 8:08 am
Thanks Jitendra Zaa.
You can find everything in Lightning PDF guide except first point.
First point I guessed from the features and functionality of Salesforce1 Mobile App.
Salesforce1 mobile app works on this concept of downloading all the components/application first before running.
Salesforce1 mobile app is also developed using Lightning Components.
That’s why I guessed first point on the basis of Salesforce1 Mobile App Functionality.
LikeLike
February 25, 2016 at 2:40 am
[…] Source: How do Lightning Components interact with Salesforce? […]
LikeLike
June 4, 2017 at 3:15 pm
In short, Salesforce Classic works on MVC architecture where C represents Server Side Controller.
But in Lightning, It works on MVCC architecture ( in simple terms ) where CC represents 2 controllers – Server side controller and Client Side Controller. Model – View – Controller(Server Side and Client Side).
LikeLike