This code gets longer if you want to properly handle errors, display a “Please Wait” message while Apex is busy, etc. and to make matters worse, this code has to be written from any component who needs to call the Apex server-side controllers!
Also, don’t forget that Lightning Components run in “system mode” and you could accidentally expose information that the users should not see. Sure, you can write Apex code that protects you from this type of accidents, but you have to write the code every time you make a SOQL or a DML… More code to write!
After a lot of thinking on how to efficiently call an Apex class from Lightning components and process the data securely in a way that is easy to implement and reusable, I came out with a design pattern that I call ApexBridge.
I have also written and polished a set of files (Lightning Components bundles and Apex classes) that implement this design pattern. I have used these files in few projects that I have worked with and I have saved about 50% development time thanks to the implementation of this design pattern. I found this library so useful, that I decided to share it with you, so I created a GitHub repository, named ETLC_ApexBridge, that hosts the library and I wrote some documentation to help you understand how to use it in your own projects.