For example, I have four functions:
var f1 = function() {...};
var f2 = function() {...};
var f3 = function() {...};
var f4 = function() {...};
var fmain = function() {...};
The main function is a for loop:
var fmain = function () {
angular.forEach(question_list, function (question, key) {
f3(); //I want to execute f4() after f3() is returned!
f4();
});
};
In f3(), f2() is called!
var f2() = function(){
//There's a timeout function to check if the dynamic value equals to the expected value
//if so, then return true; otherwise, keep calling f2() until the dynamic value equals to the expected value
}
In f2(), f1() is called!
var f1() = function(){
//There's a timeout function to check if the dynamic value equals to the expected value
//if so, then return true; otherwise, keep calling f1() until the dynamic value equals to the expected value
}
So, f3 depends on f2, f2 depends on f1.
I want to have them return synchronously (Need the code not to proceed to next line if the previous line is not returned yet). How can I implement this?
Thanks in advance!