Promise in Lightning Component
During one of the recruitment interview, I was asked a question about, how will you handle dependent callouts in lightning component initialization? And within no time, I responded we can make use of custom events; But, is custom event a good solution?? Lets, analyse a scenario to answer the question: Business wants a custom lightning component for managers to be able to see all the immediate subordinates and accounts owned by them. This can be easily achieved by any of the following Solution 1: Use nested callbacks Solution 2: Use init and a custom event Solution 3: Use promises