3
loadContact : function(component) {

    var action = component.get("c.getContact");

    action.setParams({    
        contactId : component.get("v.contactId")
    });

    action.setCallback(this, function(a) {   

    });

    $A.enqueueAction(action);
}

Instead of enqueueAction is there an alternative where I can immediately call the function? $A.enqueueAction(action) leads to a delay and few items are displayed after some time. Any inputs?

2 Answers 2

2

Since Summer '17 Lightning Data Service allows to load record by means of only markup of component

In a nutshell, Lightning Data Service provides reusable Aura components that:

  • Minimize XMLHttpRequests (XHRs)
  • Fetch records once, reducing network transfers, app server load, and database server load
  • Cache record data on the client, separate from component metadata
  • Share record data across components
  • Enable progressive record loading, caching, and merging more fields and layouts into the cache
  • Enable proactive cache population
  • Promote consistency by using only one instance of the record data across multiple components
  • Create notifications when record data changes

If you have a Lightning application that creates, reads, updates, or deletes records, LDS is the best, most efficient way to do CRUD operations.

Example of usage:

<force:recordData aura:id="forceRecordCmp" 
  <!-- aura:id is required to reference the component in your Javascript controller -->
    recordId="{!v.recordId}"
    layoutType="{!v.layout}"
    fields="{!v.fieldsToQuery}"
    mode="VIEW"
    targetRecord="{!v.record}"
    targetFields="{!v.simpleRecord}" 
    targetError="{!v.error}"
/>
0

The action needs to hit the server. Making the call synchronous would hurt the performance of the application and thus is not allowed.

2
  • So in that case how do we remove the delay . For e.g. , If I have return a custom code to create case , contact it take around 4-5 seconds. I want to remove that delay.
    – Nikx
    Commented Jan 4, 2016 at 9:51
  • 3
    Wow thats long. Its hard to know why it is taking so long, It certainly shouldn't. Multiple actions will get grouped into one XHR request, so maybe another action is really doing the long work and delaying your action.
    – Kris Gray
    Commented Jan 6, 2016 at 21:25

You must log in to answer this question.

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