Created
December 25, 2017 19:26
-
-
Save sashaegorov/dd195ba4c213c83fd65e4039bfc92f90 to your computer and use it in GitHub Desktop.
Await and Sleep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sleep (time, arg) { | |
console.log(`Sleep started for ${arg}...`); | |
return new Promise((resolve) => { | |
setTimeout(() => { | |
resolve(arg); | |
}, time); | |
}); | |
} | |
await sleep(1000, this.report.pagination.pageNumber) | |
.then((a) => { | |
console.log(`Sleep stopped ${a}...`); | |
console.log(`Sleep stopped ${this}!`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment