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

Popular posts from this blog

xslt - Substring before throwing error -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -