Created
May 4, 2020 08:24
-
-
Save lostsnow/4b47afe9694faad3bab28f5312d2d100 to your computer and use it in GitHub Desktop.
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
let sessionId; | |
async function waitOnSign() { | |
return new Promise(resolve => { | |
let chk = setInterval(() => { | |
if (sessionId) { | |
clearInterval(chk) | |
resolve(sessionId) | |
} | |
}, 100); | |
}); | |
} | |
async function asyncCall() { | |
console.log('calling'); | |
const result = await waitOnSign(); | |
console.log(result); | |
} | |
asyncCall(); | |
setTimeout(() => { | |
sessionId = "xxxxx" | |
}, 2000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment