Newer Version Available

This content describes an older version of this product. View Latest

getCallback()

Use $A.getCallback() to wrap any code that modifies a component outside the normal rerendering lifecycle, such as in a setTimeout() call. The $A.getCallback() call ensures that the framework rerenders the modified component and processes any enqueued actions.

Don't use $A.getCallback() if your code is executed as part of the framework's call stack. For example, your code is handling an event or in the callback for an Apex controller action.

Signature

getCallback (function callback)

Parameters

callback
Type: function
The method to call after establishing an Aura context.

Sample Code

1window.setTimeout(
2    $A.getCallback(function() {
3        cmp.set("v.visible", true);
4    }), 5000
5);