The Lightning Developer Guide states:
All the action calls are asynchronous and run in
It seems that the
aura:doneWaitingevent might fulfill that role, but I’m not clear on if there is a need to pass some specific event to the action, or if it will just handle server responses in the component’s scope.
I’m kicking of an action call (which retrieves a list of Contacts) on component init, then am attempting to pass the result to the component in a custom render function. Because of the async nature of the action, my component is rendering before the call successfully returns. Is
aura:doneWaitingthe way to go here?
I may be approaching this the wrong way and can potentially leverage how the framework handles data binding, and rerendering when underlying data changes. Will post a definitive answer if I come across one. I’d still be interested to know if comparing
Please refer to this article
When we make an Apex call using $A.enqueueAction(), the framework
waiting event to allow us to show visual indication like “waiting..”
or a “spinner” to the user
doneWaiting event is triggered to allow us to hide any visual
valueChange is fired ONLY IF the callback updates some value
rerender if a value is changed
doneRendering is eventually called
Things To Note:
- waiting and doneWaiting are always fired whenever we use $A.enqueueAction()
- However valueChange, rerender and doneRendering are only
fired if our business logic changes some attribute value of the
PS: You can use rerender() in your custom renderer to write some logic.