Activity Forums Salesforce® Discussions Why do we use $A.enqueueAction(action) in Salesforce?

  • shariq

    Member
    September 23, 2018 at 11:13 pm

    It adds the server-side controller action to the queue of actions to be executed. Rather than sending a separate request for each individual action, the framework processes the event chain and batches the actions in the queue into one request. The actions are asynchronous and have callbacks

  • Parul

    Member
    September 23, 2018 at 11:48 pm

    $A.enqueueAction(action) sends the request the server. More precisely, it adds the call to the queue of asynchronous server calls. That queue is an optimization feature of Lightning.

    ({
    doInit : function(component, event) {
        var action = component.get("c.findAll");
        action.setCallback(this, function(a) {
            component.set("v.contacts", a.getReturnValue());
        });
        $A.enqueueAction(action);
    }
    })

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos