How should I loop through asynchronous functions that rely on the previous loop's value?

后端 未结 1 900
庸人自扰
庸人自扰 2021-01-22 01:08

The synchronous version (simplified for readability) of what I\'m trying to do in node.js:

var value = null;
var allValues = [];
do{
  value = getValue(value); /         


        
1条回答
  •  悲哀的现实
    2021-01-22 01:31

    I'll hit a stack limit

    No, you won't. If they're really asynchronous, then the next call to iteratGetValue will be in a new stack frame - originating in the top-level execution context of the async callback handler. It's the same for Promises - some of which are even required to be asynchronous.

    0 讨论(0)
提交回复
热议问题