Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kevinhooke/3272f9faf8af8a2bb6a9199f37635482 to your computer and use it in GitHub Desktop.
Save kevinhooke/3272f9faf8af8a2bb6a9199f37635482 to your computer and use it in GitHub Desktop.
Javascript Promises
let example = new Promise(
function(resolve, reject){
let success = do some async task;
if(success){
resolve();
}else{
reject();
}
};
);
example.then(
success => //do something with success value, //note: this is the function passed for resolve()
error => //do something with error //note: this is the function passed for reject()
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment