1

On a Lightning Component, when calling an action on the Apex back-end using $A.enqueueAction(...), it takes a whileee to complete (up to 30 secs!). The action in the back-end is just a simple DML.

By reading the docs and inspecting the browser network debug logs, we understand this is because the actions are hold in a queue till some sort of poller/spooler thread processes it and dispatches these all together to the backed.

  • Is there a way to execute actions inmediately, without enqueuing? Or control the frequency of the dispatching job?
  • Or is it that we are something wrong, and $A.enqueueAction(...) is not the correct way to invoke an @AuraEnabled Apex method?

Thanks a lot!

1
  • Do you have any examples of the code where you are seeing this delay? The action queue should go back to the server pretty immediately unless there are other events kicking off.
    – pchittum
    Commented Oct 16, 2015 at 7:47

1 Answer 1

1

When you execute lightning framework actions outside the component lifecycle you have to wrap your code in a function and call it like this:

$A.getCallback(function () {//your code});

This problem usually happens when you are binding framework actions to UI events using a library like jQuery:

$(button).on('click', function () { $A.enqueueAction(myAction); // Force the queue to execute the actions immediately $A.getCallback(function () {}); });

Hope this can help. Thanks !

You must log in to answer this question.

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