Asynchronous Calls and Recursion with Node.js

后端 未结 6 847
[愿得一人]
[愿得一人] 2021-02-09 10:34

I\'m looking to execute a callback upon the full completion of a recursive function that can go on for an undetermined amount of time. I\'m struggling with async issues and was

6条回答
  •  忘掉有多难
    2021-02-09 11:19

    Build your code from this example:

    var udpate = function (callback){
        //Do stuff
        callback(null);
    }
    
    function doUpdate() {
        update(updateDone)
    }
    
    function updateDone(err) {
        if (err)
            throw err;
        else
            doUpdate()
    }
    
    doUpdate();
    

提交回复
热议问题