2017-04-24 53 views
-1

spec saysPromise如何解決並等待處理?

甲解決承諾可能正在申請,滿足或拒絕。

Promise如何解決並等待處理?

+4

[什麼是Javascript的承諾正確的術語(HTTP://計算器.com/questions/29268569/what-is-correct-terminology-for-javascript-promises#answer-29269515) – destoryer

+1

解決!=履行 – Bergi

+0

好的謝謝。我知道了。解決方案還涵蓋了外部承諾的狀態與內部狀態的約束。因此,外在承諾可能正在等待(內在的承諾),並得到解決。 – Ben

回答

2

它是正確的,在該部分中,您鏈接到:

允諾解決如果解決,或者如果它已被「鎖定」,以配合其他承諾的狀態。 [...]

其他承諾可能仍在等待處理。讓我們看一個例子:

var p = new Promise(resolve => setTimeout(resolve, 1000)); 
var q = Promise.resolve(p); 

// At this point `q` is resolved/"locked in" but still pending 
// because the `p` promise is also still pending. 

// Only after the timeout has passed, the `p` promise will resolve/settle 
// and `q` will assume the inner promises state. 

貌似BERGI寫道圍繞承諾術語一個非常全面的回答:What is the correct terminology for javascript promises