In lightning or VF page, there is usually more than one set of data need to be initialized. Say if we have two list of SObjects of different type need to get queried/initialized from database, what should we do in this case. I am currently using multiple enqueued actions to achieve this, as in the below code:
var action = component.get("c.getCurMessage");
action.setCallback(this, function(response) {
//...
});
$A.enqueueAction(action);
}
var action2 = component.get("c.getHelperList");
action2.setCallback(this, function(response) {
//...
});
$A.enqueueAction(action2);
This can resolve the issue. But the disadvantage about this method is obvious - it needs multiple server calls to retrieve the data. I have thinked about using a JSON string to carry all the data to front-end side and analyze the string in front-end but it will obviously make code very complex. Is there a better way of doing this?