javascript - How to call a function repeatedly after it finishes? -
i want call function main() contains lot of asynchronous db-connection calls. want call function repeatedly after iteration of main() gets finished.
how should in nodejs? think there way use promises on here this. not able think in correct direction.
use promise.all wait promises finish.
https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/promise/all
afterwards can call .then(main)
function main() { var promises = []; promises.push(...); promises.push(...); ... promise.all(promises).then(main); }
Comments
Post a Comment