2

When doing development with Lightning, I've noticed that the order events are fired/handled are not deterministic (this makes perfect sense given the architecture of Lightning). Unfortunately, what I've now found is that if my computer is not running at optimal speeds (say I'm running a high usage application while accessing Salesforce) items that must be in order may not be. Take this example:

I want to have a spinner show when an action is being performed and then have it disappear when the action completes. In order to accomplish this, I listen for the aura:waiting event and show the spinner when it fires. I then listen for the aura:doneWaiting event to hide the spinner. This normally works great and makes things extremely simple because I have this logic in my outer most component so all actions within are handled in one place. Unfortunately, what has been happening when I have less resources for the browser is that the aura:doneWaiting events are handled after the aura:waiting events, causing a spinner to show that is never hidden.

event order

Has anyone seen this occur? Is this expected behavior? Any thoughts on how to resolve this issue?

This issue has had no responses so was not relevant

This issue says I shouldn't use these events which I struggle with (why are they still firing if they're legacy?

Thanks!

  • are there multiple call to server action? – Manjot Singh Feb 1 '17 at 19:05
  • There can be multiple calls, yes. – techbusinessman Feb 1 '17 at 19:07
  • aura:waiting and donewaiting is fired for every call. so that might be reason for this. – Manjot Singh Feb 1 '17 at 19:19
  • It is not. The issue is as I described (and as shown in the picture) the doneWaiting events are handled before the waiting events. If this wasn't the issue, the last waiting event would have fired. – techbusinessman Feb 1 '17 at 19:22
  • 1
    IMO the potentially unreliable behavior and potential lack of support in the future for this event makes using it not worth it, despite the convenience. I highly recommend managing the spinner yourself for actions you own and know may need a spinner displayed for. – TrevorBliss Feb 3 '17 at 18:49
4

Use of Aura:donewaiting is not recommended by salesforce. As in there documentation

We don't recommend using the legacy aura:doneWaiting event except as a last resort. The aura:doneWaiting application event is fired for every server response, even for responses from other components in your app. Unless your component is running in complete isolation in a standalone app and not included in Lightning Experience or Salesforce1, you probably don’t want to handle this application event. The container app may fire server-side actions and trigger your event handler multiple times.

  • Thanks for this reply. I did read this, and I took it to mean that if my app is not being used in LEX or SF1, as a stand alone app, then these events could be used (my app is completely stand alone). – techbusinessman Feb 1 '17 at 19:47

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.