JSFiddle - React, Tailwind, and code Playground
JavaScript
var isValid = undefined;
codeEditAddress();
function codeEditAddress() {
test();
waitFor(function() { return isValid != undefined }, function(){ alert("Finished!"); });
alert("777");
}
function test(){
setTimeout(function(){isValid = true;}, 1000);
}
function waitFor(fnReady, fnCallback) {
var check = function () {
if (fnReady()) {
fnCallback();
}
else {
setTimeout(check, 100); // wait another 100ms, and try again
}
};
check();
}