6

Is there a way to have access to data from Apex immediately when the lightning component is loading? I know that in the early days of Lightning Components I was able to do it with an Apex Model. However, I believe that concept never made it into the final, released version of Lightning Components.

Right now my best way of getting data into my components from Apex is through an init handler in my component that invokes an action. This seems a bit slow because I have to do another round trip to Salesforce to get my data.

Am I missing something simple, or is the init handler approach the correct way. Also as a side node, is the concept of "Models" totally gone from Lightning Components? I did see a small reference to them in the documentation, but that could be a remnant from older documentation.

Below is my network console from Chrome when I'm loading up a Lightning App.

Network Console from Chrome

The first green line "Test.app" is the first response from the browser and took 1.83 seconds. This loads up the Lightning Components runtime. The second green line is my app and components loading and took 1.96 seconds. Once this is finished, finally my init handler is run and I am able to make a request to one of my Apex Controller functions and get data back. I understand that the 4.22 seconds there is my code and I'm responsible for the performance there.

Is it truly the case that 4 seconds will pass loading up Lightning Components before I can even start running my Apex code, or is there a way to maybe get data back from the Test.app request or the first aura xhr request?

1
  • 1
    I feel that gap, too. Sometimes even for simple components: they pop up and a bit later populate. Would be nice to save the initial roundtrip somehow and get that queued into one call.
    – Uwe Heim
    Oct 21, 2015 at 12:15

1 Answer 1

0

Models were removed from Lightning Components, and there are no plans to support them. What are you retrieving from Apex, and what sort of performance are you getting?

1
  • Edited my question with clarification and more data. Jul 7, 2015 at 18:27

You must log in to answer this question.

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