|
otakustayJan 10, 2015 via iPhone
1
.then(final, final)
|
|
2
@otakustay 这样子不是要重复写二遍代码,或者要先定义一个函数,无论哪个都不方便。我是说别的异步库都有finally功能反而官方的Promise没有这不太合理,毕竟这个功能很常用的。
|
|
otakustayJan 10, 2015
4
那么……
Promise.prototype.ensure = function (callback) { this.then(callback, callback); } |
|
otakustayJan 10, 2015
5
|
|
6
@otakustay 是的我也看到了,还有一个比较完善的polyfill https://github.com/matthew-andrews/Promise.prototype.finally
|
|
oott123Jan 11, 2015 via Android
7
诶…?我记得我用的 Q 就有 finally 方法啊…
|
|
oott123Jan 11, 2015 via Android
8
抱歉抱歉,没看到楼主说的 ES6。
→_→或许可以考虑第三方库… |
|
leonluJan 12, 2015
9
哈哈, 给ES6的标准委员会发邮件呀, 提需求去...
|