A basic understanding of the sequence of steps that takes place when a Lightning Component communicates with a client and a server will help a great deal before we dive deep into how to build a Lightning Component.
The following diagram shows how a Lightning Component works between the client and server:
The key things to note from the previous diagram are as follows:
- A user action instantiates the component and an init event is raised
- The JavaScript controller function calls the helper function to perform any server-side action
- The Apex controller method is invoked from the helper function, the data is returned, and JavaScript callback functions are invoked
- The JavaScript client-side logic can be written to manipulate the DOM, set attributes, and refresh the view