How JavaScript promises work

Last week we looked at callbacks and promises. I made a case for using promises to easily coordinate asynchronous code. This week, we’ll dig further into understanding promises and look at the syntax.

Imagine you have a box. You don’t know if there’s anything in the box yet, but you can carry it around and say things about it, like:

“This box is meant to have a gift inside.”
“If the gift is in the box, I should tell everyone the gift is here.”
“If the gift is in the box, I should also write a thank you note.”
“If there’s a letter in the box saying the gift was out of stock, I should go order a different gift.”

To read this article in full, please click here

(Insider Story)

分類: Android News 安卓新聞, IT 資訊科技(信息技术), 熱門新聞,標籤: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , 。這篇內容的永久連結