I'm trying to loop a function with a setInterval and then, when a condition is hitted:
- Pause the setInterval loop
- Call and execute an async function
- Resume the setInterval loop
What's the best way to do it in Javascript? I have something like this:
var refreshId = setInterval(Myfunction, 5);
function Myfunction(){
---do something---
if (conditionIsHitted){
externalFunction();}
}
---resume the setInterval loop again