Created
January 15, 2017 07:38
-
-
Save bananaumai/41771d154645cd0a96a68380d79c9729 to your computer and use it in GitHub Desktop.
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
const delayed_yeah = () => { | |
console.log('delayed_yeah!') | |
return new Promise((resolve, reject) => { | |
setTimeout(() => resolve('yeah!'), 2000) | |
}) | |
} | |
const delayed_hi = () => { | |
console.log('delayed_hi!') | |
return new Promise((resolve, reject) => { | |
setTimeout(() => resolve('hi!'), 2000) | |
}) | |
} | |
const awfn = async () => { | |
console.log('before delayed yeah') | |
const yeah = await delayed_yeah() | |
console.log('before delayed hi') | |
const hi = await delayed_hi() | |
console.log(yeah, hi) | |
} | |
let counter = 0 | |
const timeout = setInterval(() => { | |
if (counter === 5) awfn() | |
console.log(counter) | |
counter++ | |
}, 1000) | |
setTimeout(() => clearInterval(timeout), 10000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment