Storable actions
In Chapter 3, Lightning Component Building Blocks, you learned that, to make a call to a server (using the Apex method) from the Lightning Component client-side controller/helper
function, we can enqueue an action, using the following code snippet:
var action = component.get("c.getResults"); action.setCallback(this, function(response) { // handle response }; $A.enqueueAction(action);
In the code snippet, whenever an action is invoked via events (onInit
, click
, or custom events), the client makes a call to get the latest data or performs data manipulation (DML), such as the creating, deleting, or editing of records.
This framework provides the ability to mark an action as storable. To mark an action as storable, the code snippet is as follows (pay special attention to the highlighted line):
var action = component.get("c.getResults");
action.setStorable();
action.setCallback(this, function(response) {
// handle response
};
$A.enqueueAction(action);
When an action is marked...