Skip to content

Instantly share code, notes, and snippets.

@iamspark1e
Created August 24, 2023 07:09
Show Gist options
  • Save iamspark1e/b193fc1e7768446948b6a637a6288b00 to your computer and use it in GitHub Desktop.
Save iamspark1e/b193fc1e7768446948b6a637a6288b00 to your computer and use it in GitHub Desktop.
let status = false;
let iframeReq = () => {
return new Promise((resolve, reject) => {
let timeout = 10;
let counter = 0;
let timer = setInterval(() => {
if(!status) {
if(counter < timeout) {
counter++;
} else {
reject();
clearInterval(timer);
}
} else {
resolve();
clearInterval(timer);
}
}, 1000)
})
}
setTimeout(() => {
status = true
}, 5000)
iframeReq().then(() => {console.log(status)})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment