A Lightning Component – lets call it component B – can define a method (that can have arguments) like this:
<aura:method name="doAbc" action="{!c.doAbc}"/>
that can be called from another component – lets call it component A – quite simply in the controller or helper JavaScript:
cmpB.doAbc();
But this is implemented inside the framework via an event:
var eventDef = $A.$eventService$.$getEventDef$("aura:methodCall");
and so is asynchronous. The JavaScript code immediately after the call can't rely on the side effects of the call and also there is no way such a method call can have a return value.
Is there a simple pattern that can be used to achieve (or simulate) a synchronous call between two components?
Best Answer
I believe those calls are synchronous. I have code like this:
Your method def: