我是新来的JavaScript承诺,但直接蝙蝠我注意到,如果你使用的承诺实现以外的浏览器提供的,有一些不同......突出的是Promise.cancel
方法。承诺取消方法。为什么它尚未实现,而不是其他Promises框架?
这是可见的,当你使用链式承诺:
myPromise.then(this.view.firstMethod)
.then(this.view.secondMethod) // Fails, need to cancel the chain!
.then(this.view.thirdMethod)
.then(this.view.fourthMethod);
使用WinJS.Promise
到取消链的承诺:https://jsbin.com/tuviqi/edit?js,console正确地显示在控制台:
0
1
使用Promise
对象从浏览器取消相同的链接承诺:https://jsbin.com/morazi/edit?js,console并显示
0
1
"Error in secondMethod."
undefined
我还使用catch
这是ES6糖尝试:https://jsbin.com/goqixal/edit?js,console - 但得到:
0
1
"Error in secondMethod."
undefined <--- jsbin doesn't show this, look into console
我浏览到https://github.com/promises-aplus/cancellation-spec/issues/1 - 但为什么这个停顿是我不清楚。
当从浏览器中使用Promise
我想链1,2和内部2链3,4?