I have an async function which contains an awaited method in it, and since async/await are non-blocking, the moment the thread hits await in my notifyCustomer() method, it exits the method and proceeds to do other synchronous tasks.
async function notifyCustomer() {
console.log("in notifyy customer");
const customer = await getCustomer(1);
//rest of my method
}
notifyCustomer();
//multiple intensive for loops running to consume time
The problem is, these multiple synchronous loops after my notifyCustomer() method would take about 20 seconds to execute, which means that for the thread to return to my notifyCustomer() method, I would have to wait for all of those for loops to end. Is there a way to check after finishing each of the for loops if my awaited customer is done so I can finish the rest of my async function before returning to finishing with my for loops? So that I dont have to wait for all of my code to finish running before I can get back to notifyCustomer.