Foreground and Background Actions in Lightning Components

foreground and background actions in lightning components,foreground action,background action, setbackground action

Foreground Action:-

In Lighnting actions are foreground by default you can see that in above GIF that whenever i click on Fire Foreground Action button it sends a single request to server where you can see that in bottom of Inspect Element

In this Foreground action, response won’t be returned to client till the running request gets completed.

Background Action:-

If you want the UI to be more responsive to a user then you need to go with background action which will make the actions to run in separate that. I.e, It will send a separate request thread instead of sending as one request to server.

In the above GIF you can see that whenever i click on Fire Background Action button, first it will send getAccount as one request and getContact in other request, So it may be useful where you want your component to be more responsive.

Working code has been given below,

Be the first to comment

Leave a Reply

Your email address will not be published.