javascript - How to know when a recursive, asynchronous task finishes -


i have async function, can recurse itself.

i'm adding jquery deferreds array each time function runs, use $.when() check if promises have resolved. issue can't seem without arbitary timeout, don't know when function stops recursing , adding new promises.

do push promises synchronously, know when finished. since function recursive , returns promise, can use result promises of recursive calls this. use $.when() results of current recursion level, not promises in call stack.

also check answers understanding promises in node.js recursive function , is there example of using raw q promise library node recursively traverse directory asynchronously? - though they're not using jquery's implementation, should give idea of how it.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -