A
A
Andrey Rogov2015-11-09 10:39:46
JavaScript
Andrey Rogov, 2015-11-09 10:39:46

Is there a sequential Promise.all?

Here is an array of promises:

var arr = ['a', 'b', 'c'];
var promises = arr.map(function(str) {
  return new Promise(function(resolve, reject) {
    console.log(str);
    setTimeout(resolve, 1000);
  });
});

How to execute this array sequentially (in 3 seconds)?
Is there a generally accepted way to do this?
I don’t believe that every time a bicycle is written or they climb into npm.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yaroslav Lyzlov, 2015-11-09
@rogallic

No.
It can be done in a loop, like we take a promise, execute it and return the next one in it. Then there will be a chain. I don't understand about 3 seconds.

A
Alexander Taratin, 2015-11-09
@Taraflex

https://jsfiddle.net/QW01_01/pt8f18vb/1/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question