Created
April 8, 2019 08:20
-
-
Save anthify/3703d336e723ea86e8bc2b3b4544dcf1 to your computer and use it in GitHub Desktop.
Async Await Delay
This file contains hidden or 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
export default time => | |
new Promise(resolve => setTimeout(() => resolve(), time)); | |
// example | |
import delay from '.' | |
const stopAndStart = async () => { | |
console.log('๐'); | |
await delay(1000); | |
console.log('๐, one second later'); | |
}; | |
stopAndStart(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment