5

Good afternoon everyone,

I have a question regarding the use of the aura:waiting and aura:doneWaiting system events. I currently have two nested child components within a container component as you can see in the below markup:

<div class="row">
            <div class="col-md-6">
                <c:SelfServiceExistingCases />
            </div>
            <div class="col-md-6">
                <c:SelfServiceCaseDetail />
            </div>
 </div>

In each component, there are asynchronous calls to the server that occur where I am showing and hiding the component on <aura:waiting> and <aura:doneWaiting>. However, what I am seeing is that when I perform an interaction that fires an async call on the SelfServiceExistingCases component, the spinner event fires on both the SelfServiceExistingCases and SelfServiceCaseDetail components. No waiting event should fire for the SelfServiceCaseDetail component because it is a completely separate component and no interaction occurred with it in this case.

I assumed these two system events were component specific but are they firing at the application level by default instead of the component level? Ideally, I would only want the spinner to show within the component that is waiting for a server response and not all sibling components in the containing component.

Also just to note, there I have not specified any <aura:waiting> or <aura:doneWaiting> event on the containing component.

Thanks!

  • To clarify, I'm mainly wondering if <aura:waiting> and <aura:doneWaiting> are application or component events? It seems like they are behaving as application events. – Daniel Fuller Aug 12 '15 at 22:21
  • One more clarification, the detail child component mentioned above currently is not making any server calls. I commented out the server call it was making so there is no queued action on that component and it is still handling an aura:waiting event, apparently fired by its sibling. I have also now seen that this event bubbles up to the application level. Is this a bug? If not, how would it be possible to only show waiting indicators in nested child components that are legitimately waiting for a response? – Daniel Fuller Aug 12 '15 at 22:54
4

Yes both aura:waiting and aura:doneWaiting are application level events.

Those events are kind of legacy from the very first design of the framework years ago, and we do not recommend its use for any sort of component notification or async operation, precisely because of the issues you just run into.

Those were meant to be used by an application so you can tell when the application is ready. I think we should add those facts into our documentation, so more devs don't run into the same problem.

If you are doing an async operation mostly you will have a callback out of that, and you could fire an event (either application or component type event) if you want to notify someone else.

  • Thanks for that information, Diego. What would be your recommendation for showing a spinner in specific components that are waiting for async operations to complete as far as a operation status you would poll or something like that? – Daniel Fuller Sep 29 '15 at 17:05
  • Most of async operations will have a callback, so I would suggest you toggle the spinner state there. You could also do it in the rerender of the component itself if you specifically are changing an attribute on it. – Diego Sep 30 '15 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.