I'm using await within an async function execute functions in a particular order, if you see here - I wanted startAnim
to wait until hideMoveUI
had finished executing to execute itself.
Though my console log returns:
startAnim
hideMoveUI
My code:
async function printAll() {
await hideMoveUI();
await startAnim();
}
printAll();
hideMoveUI = () => {
setTimeout(() => {
console.log('hideMoveUI');
}, 3000);
}
startAnim =() => {
setTimeout(() => {
console.log('startAnim');
}, 500);
}
Is setTimeout
an async
function?
How can I make the second function wait for the first one to finish? any help or advice is appreciated. Thank you in advance.