function step1(){ return new Promise(function(c,e){ setTimeout(function(){ c(`1000 spet 1`); },1000) }) } function step2(){ return new Promise(function(c,e){ setTimeout(function(){ c(`100 spet 2`); },10000) }) } function step3(){ return new Promise(function(c,e){ setTimeout(function(){ c(`3000 spet 3`); },3000) }) } function step4(){ return new Promise(function(c,e){ setTimeout(function(){ c(`100 spet 4`); },100) }) } function *main() { var ret = yield step1(); try { ret = yield step2( ret ); } catch (err) { ret = yield step2Failed( err ); } ret = yield Promise.all( [ step3( ret ) ] ); yield step4( ret ); } var it = main(); Promise.all( [ ...it ] )
source share