我愿意:
return new bluebird((resolve) => {
bluebird.resolve()
.tap(saveExcelFiles)
.tap(...)
.tap(() => {
return getZip().then((rows) => {
resolve(rows) // this outer bluebird helps me
return rows;
});
})
;
});
如何返回所有数据(每次点击)或仅在一个 bluebird 包装中返回最后一次点击。
附注我需要排序(一点一点,一点一点)
最佳答案
.tap
明确表示“忽略返回值”,如果您需要返回值 - 使用标准 .then
:
.then(() => {
return getZip().then((rows) => {
// Nothing outer.
return rows;
});
});
或者更紧凑:
.then(getZip); // that's it!
此外,您应该返回
promise 链而不是 explicit construction :
return saveExcelFiles().tap(...).then(getZip);
对于整个函数来说应该足够了。
关于javascript - (bluebird .tap) 无法返回数据,做错了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46651405/