Promise をつなげる
2019.03.24 15:26
直列
Promise.resolve().then(function(){
return new Promise(function(resolve, reject){
resolve()
})
}).then(function(){
return new Promise(function(resolve, reject){
resolve()
})
}).then(function(){
return new Promise(function(resolve, reject){
resolve()
})
})
並列
const promiseArray = [];
const initializeInit = new Promise((resolve, reject) => {
resolve();
})
promiseArray.push(initializeInit);
const initializeStyle = new Promise((resolve, reject) => {
resolve();
})
promiseArray.push(initializeStyle);
return new Promise((resolve, reject) => {
Promise.all(promiseArray).then(() => {
resolve();
})
})
(参考記事)