Created
July 19, 2020 16:50
-
-
Save avivshafir/9dcebbabf841eaf18726b6d089cc499a to your computer and use it in GitHub Desktop.
example
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
let counter = 1; | |
function doInDelay(counterRecieved) { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
if (counter > counterRecieved) { | |
return; | |
} | |
resolve("Hi") //do filter | |
}, 2000) | |
}) | |
} | |
(async() => { | |
console.log(await doInDelay()); | |
const onClick = async () => { | |
counter++; | |
const results = await doInDelay(counterRecieved); | |
//use results... | |
} | |
})() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment