Skip to content

Instantly share code, notes, and snippets.

@lostsnow
Created May 4, 2020 08:24
Show Gist options
  • Save lostsnow/4b47afe9694faad3bab28f5312d2d100 to your computer and use it in GitHub Desktop.
Save lostsnow/4b47afe9694faad3bab28f5312d2d100 to your computer and use it in GitHub Desktop.
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