How to ensure all the async calls are back in javascript -
i have piece of javascript code doing
function asyncs(){ var backcount = 0; function done(){ if(backcount === 2){ alert("all done"); dosomthinguseful(); }else{ backcount ++; } } function asynccall(callback){ myremotecall(callback); } asynccall(done); asynccall(done); asynccall(done); } function dosomethinguseful(){ alert("travel moon.") }
this working. wondering if there better approach don't have write ugly counter function.
i recommend using flow control library async or nimble handle sort of thing. internally pretty same thing gives them in reusable patterns.
Comments
Post a Comment