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

The promises object

The promises object is the last of the major concepts of asynchronous programming model implemented. We will be looking at promise as a design pattern.

Promise is a relatively new concept in JavaScript, but it's been around for a long time and has been implemented in other languages.

Promise is an abstraction that contains two main properties, which make them easier to work with:

  • You can attach more than one callback with a single promise
  • Values and states (errors) get passed along
  • Due to these properties, a promise makes common asynchronous patterns using callback easy

A promise can be defined as:

A promise is an observable token given from one object to another. Promises wrap an operation and notify their observers when the operation either succeeds or fails.

The source of this definition is Design Patterns: Elements of Reusable Object-Oriented Software, Addison-Wesley Professional.

Since the scope of this book revolves around the promise and how it is implemented, we will discuss it in greater detail in Chapter 3, The Promise Paradigm.

主站蜘蛛池模板: 宁波市| 涿鹿县| 盐津县| 洛阳市| 故城县| 同江市| 青河县| 宜宾市| 上虞市| 黔西| 开平市| 昌图县| 靖远县| 张家界市| 伊吾县| 西吉县| 新民市| 水富县| 法库县| 莱阳市| 泸州市| 庄河市| 长泰县| 宝丰县| 邛崃市| 黎平县| 铁岭县| 黑河市| 淮南市| 临泽县| 镇巴县| 比如县| 镇远县| 蒙自县| 惠东县| 威远县| 枞阳县| 兴和县| 清苑县| 阿克| 呈贡县|