简体   繁体   English

Promise.Promise中的承诺都没有执行

[英]Promises within Promise.all not getting executed

Could someone help me why the promise within the promise.all ie ( suggestRC and suggestGL) are not getting called? 有人可以帮助我,为什么没有在promise.all(即recomeRC和suggestGL)内的诺言被调用? I would like to make sure the suggestRC and suggestGL are executed concurrently. 我想确保describeRC和proposalGL同时执行。 That was the reason, I had written like this. 这就是原因,我这样写。 extractIdeas is getting called but suggestRC and suggestGL are not getting called. 调用了extractIdeas,但是未调用describeRC和proposalGL。

function suggestValues(editIdeaPanel) {

    Requests.deckreposvc({searchIdeas: {searchString: searchReq}})
        .then(extractIdeas)
        .then(Promise.all([suggestRC, suggestGL]))
        .catch(handleError);
}

function extractIdeas(searchRes) {
    return searchRes.searchIdeas.data;
}


function suggestRC(ideas) {
    return new Promise(function(resolve, reject) {
              //do something 
        }
        resolve(ideas);
    });
}

function suggestGL(ideas) {
    return new Promise(function(resolve, reject) {
    if(!editIdeaPanel.wdGLeaderCombo.propertyValue.uuid) {
           //do something
    }
        resolve(ideas);
    });
}

You need to call those two functions (add parentheses) in a callback that you pass to then : 您需要在传递给then回调调用这两个函数(添加括号):

.then(data => Promise.all([suggestRC(data), suggestGL(data)]))

Also, you will want suggestValues to return the promise: 另外,您将希望草率建议值return承诺:

return Requests.deckreposvc( //...etc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM