I have a parent component and 3 child components ( 3 or more will be created dynamically). On click of a button in parent component, i am firing a component event and this event is handled by all my child components (direct childs of parent).

I need to control the spinner visibility until child handler actions are completed and user has to wait.

Please guide me how to track this event handler action status in lightning.

1 Answer 1


When you fire an event, control returns to the place where you fired it immediately afterwards. So, as long as the handlers are just performing synchronous actions, you can just write it sequentially i.e.

// hide the spinner

If the handlers are doing asynchronous stuff (e.g. calling Apex), then you will probably need to get them to fire an event on completion of their actions and handle those events in the parent.

At which point, the question is: how do you know how many children to wait for?

Well, the handlers in the children (from the first event) can actually add data to the first event as they handle it. So, they can add themselves to a list in the event so that the parent knows how many to wait for i.e.

childEventHandler : function(component, event, helper) {
  var childGlobalIds = event.getParam('childGlobalIds');
  if($A.util.isEmpty(childGlobalIds)) {
    childGlobalIds = [component.getGlobalId()];
  } else {

And then in the parent:

var childrenToWaitFor = event.getParam('childGlobalIds');

So the parent handler can just tick off the global ids and hide the spinner when they are all done.

  • Thanks for your reply. I have done similar approach checking how many child components are there and how many of their actions completed. Is there any other standard way to make it simple ? (just curious).
    – brahma
    Oct 15, 2017 at 12:29
  • Never seen a simpler way - unless someone comes up with a better answer. You could maybe do it by using aura:methods in the children that return promises. But that's quite a bit change to using events
    – Aidan
    Oct 16, 2017 at 8:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .