0
Bluebird对于解析链有没有任何方便的方法,其中每个元素的输入都是前一个元素的解析值(除非它不是函数)?Bluebird的链接结果
我试图链以下逻辑成一个单一的方法:
function getClient() {
// resolves with the client
}
function getClientProduct(client) {
// resolves with the product
}
var response = {}; // global response object;
function prepareResponse(product) {
// prepares global response object, resolves with `undefined`
}
promise.someMethod(getClient, getClientProduct, prepareResponse, response)
.then(data=> {
// data = the response object;
});
我想避免不必编写以下的(如果可能的话):
getClient()
.then(client=>getClientProduct(client))
.then(product=>prepareResponse(product))
.then(()=>response);
好的,谢谢!我以为我错过了一些东西,因为这会是一个不错的功能;) –