Skip to content

Instantly share code, notes, and snippets.

@gskachkov
Last active November 10, 2017 16:28
Show Gist options
  • Save gskachkov/93c2c8ed4af938bc63235375eff31365 to your computer and use it in GitHub Desktop.
Save gskachkov/93c2c8ed4af938bc63235375eff31365 to your computer and use it in GitHub Desktop.
const promise = new Promise(resolve => {
setTimeout(()=>resolve('success'));
});
const startOperation = () => { console.log('start'); };
const finishOperation = () => { console.log('finish'); };
startOperation();
promise
.then(
result => {
console.log('success', result);
finishOperation(); // Finish in success branch
},
error => {
console.log('success', error);
finishOperation(); // Finish in fail branch
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment