我是新來的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?