In the helper I have methods that each call an @AuraEnabled method in the component controller.
Some of these calls are only during the 'init' event. From a performance point of view I should make only one call during 'init'.
What is an elegant way of achieving this?
The methods called during 'init' return a list of strings, a decimal, and respectively a string.
Define a custom Apex class in your controller that encapsulates all of the information you wish to source in a single call from your init
event:
public class InitializationWrapper {
@AuraEnabled
public List<String> myStringList {get; set;}
@AuraEnabled
public Decimal myDecimal {get; set;}
@AuraEnabled
public String myString {get; set;}
}
The, return an instance of this wrapper class from your server-side Apex call to your init
handler. You only need to make a single round-trip.