【发布时间】:2017-03-27 13:37:57
【问题描述】:
我一直在尝试几种不同的方法来链接一组函数,但似乎找不到我特别喜欢的方法。以下是我最后确定的,但仍然不热衷。
有人可以建议一个更简洁的模式吗?我不想选择 Async.js 或库。
[
this.connectDatabase.bind(this),
this.connectServer.bind(this),
this.listen.bind(this)
].reduce(
(chain, fn) => {
let p = new Promise(fn);
chain.then(p);
return p;
},
Promise.resolve()
);
附言。任何其他提示都非常受欢迎。
【问题讨论】:
标签: node.js es6-promise