官术网_书友最值得收藏!

How do promise and deferred relate to each other?

So far, in Chapter 2, The JavaScript Asynchronous Model, we discussed promises and how they work. Let's have a look at how promises and deferred work:

  1. Every deferred object has a promise that serves as a proxy for the future result.
  2. A deferred object can be resolved or rejected by its caller, which separates the promise from the resolver, while a promise is a value returned by an asynchronous function.
  3. The promise can be given to a number of consumers and each will observe the resolution incessantly, while the resolver/deferred can be given to any number of users and the promise will be resolved by the one that first resolved it.
主站蜘蛛池模板: 徐水县| 钦州市| 宜丰县| 新巴尔虎左旗| 天祝| 三门县| 五河县| 喜德县| 昌吉市| 苏尼特右旗| 拉孜县| 和政县| 泽州县| 四子王旗| 武义县| 建湖县| 长岛县| 黑龙江省| 四平市| 积石山| 沙坪坝区| 赤城县| 和田县| 沾益县| 长垣县| 乐亭县| 通江县| 庆安县| 德江县| 来凤县| 营口市| 芒康县| 武义县| 大关县| 新余市| 阿坝| 澜沧| 奉新县| 白河县| 饶河县| 卢氏县|