Skip to content

Instantly share code, notes, and snippets.

@woliveiras
Last active February 4, 2017 11:30
Show Gist options
  • Save woliveiras/8583c9165d56e483cb2f41a86357985d to your computer and use it in GitHub Desktop.
Save woliveiras/8583c9165d56e483cb2f41a86357985d to your computer and use it in GitHub Desktop.
function printAfterTimeout(string, timeout){
return new Promise((resolve, reject) => {
setTimeout(function(){
resolve(string);
}, timeout);
});
}
printAfterTimeout('Hello ', 2e3).then((result) => {
console.log(result);
return printAfterTimeout(result + 'Reader', 2e3);
}).then((result) => {
console.log(result);
});
// Hello
// Hello Reader
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment