Skip to content

Instantly share code, notes, and snippets.

@scottmo
Created May 7, 2019 15:34
Show Gist options
  • Save scottmo/7898fa7d15ec74dd1c0b933d8113ae36 to your computer and use it in GitHub Desktop.
Save scottmo/7898fa7d15ec74dd1c0b933d8113ae36 to your computer and use it in GitHub Desktop.
Aura Snippets
function createComponent(cmp, attributes) {
return new Promise(function(resolve, reject) {
function doCreateComponent() {
$A.createComponent(cmpDef, attributes, function(newCmp, status, errorMsg) {
if (newCmp && status === 'SUCCESS') {
resolve(newCmp);
} else if (status === 'ERROR') {
reject(errorMsg);
} else if (status === 'INCOMPLETE') {
$A.getEvt('markup://force:showOfflineMessage').fire({
retryFunction: doCreateComponent
});
}
});
}
doCreateComponent();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment