Handling errors from promises . A Promise has 3 possible states:. The mechanism is implemented via promises . The previous example with Promises may look like this:.
Plus each sale benefits Pencils of Promise . Promises Don'tComeEasy(诺言来之不易).Words don't come easily(words don't come easily).All of the profits will go to Pencils of Promise . 了解Promises 的更多信息,请参阅Promises/A+. For more information on Promises , refer to the Promises/A+ specification. ES6介绍了一种被JavaScript中Promises 使用的叫做作业队列/微任务队列的概念。 ES6 introduced the concept of job queue which is used by Promises in JavaScript. 了解Promises 的更多信息,请参阅Promises/A+规范。 For more information on Promises , refer to the Promises/A+ specification. 你可能会问:当大部分库只仅仅公开一个回调接口时,我如何使用Promises ? You may ask: how can I use Promises when most of the libraries out there exposes a callback interfaces only? Promises 通常用于网络和I/O操作,例如读取文件或者发出HTTP请求。Promises are typically used for network and I/O operations- e.g. reading from a file, or making HTTP requests. 由于我们使用Promise而不是回调风格,因此必须从fs/promises 而不是fs导入。 Since we're using promises rather than callback style, it has to be imported from promises instead of directly from fs. 不幸的是,没有任何“标准”(一切都像在Javascript中其他东西)用来实施或使用Promises 。 Unfortunately, there isn't any one“standard”(like everything else in Javascript) for implementing or using Promises . 下一步,我们将看看Promises ,以及它们如何使异步编程回归到更简单、更友好的模型。 Next, we will look at Promises , and how they help to bring asynchronous programming back to a model that is simpler and more familiar. 然后我们将修改我们的代码,如下所示,它使用promises 更新Employee集合中的Employeename。 We will then modify our code as shown below, which updates an Employeename in the'Employee' collection by using promises . Js的Promises 提供了一个ensure()方法,它具备我们前面实现的所有特性,但是更简洁:. Js Promises provide an ensure() method that has all of the properties we achieved above, but also allows us to be more succinct:. ES6增添了许多必要的特性,例如:模块和类,以及一些实用特性,例如Maps、Sets、Promises 、生成器(Generators)等。 ES6 adds much needed features such as modules and classes, and some useful ones, Maps, Sets, Promises or Generators. 我们已经使用Promises 重构了简单的getTheResult函数,并且解决了在Part1提出的的两个问题。 We have used Promises to refactor our simplified getTheResult function, and fix two of the problems we identified in Part 1. 结语当然同步执行和异步执行之间总是有所差异,但是我们可以通过使用Promises 缩小这种差异。 Of course, there will always be differences between synchronous and asynchronous execution, but by using Promises , we can narrow the divide. 使用Promises ,我们可以建立一种方法,类似于友好的try/catch/finally惯用语法,并且没有深度回调结构。 Using Promises , we can build an approach that is analogous to this familiar try/catch/finally idiom, without deep callback structures. 如果Javascript已经提供或者未来可能提供其他的语言结构,那么Promises 可能会以不同的方式实现。 If Javascript provided, or possibly when it does provide in the future, other language constructs, promises could be implemented differently. 在BridgetPolk的《Promises oftheEphemeral》(短暂之许诺)中,作品着眼于无形的力量和脆弱与时间的概念。 In Bridget Polk's Promises of the Ephemeral, the work looks at the power of an invisible material and the idea of fragility and time. Tasks是GitHub上第一个可用的Bolts组件,旨在按照JavaScriptPromises 模型处理异步操作。 The first Bolts component that is available on GitHub is Tasks, aimed at handling asynchronous operations according to the JavaScript Promises model. 这种类比并不精确,因为JavaSciptpromises 比简单的列表更加复杂:它们拥有额外的特性和限制。 The analogy isn't terribly accurate, because JavaScript promises are more complex than a simple subscription list: they have additional features and limitations. 学习Javascript的最新语言特性和趋势,并学习解决与它们有关的问题(即Promises ,ES6,ES7,函数式编程技术)。 Learn the newest language features and trends in Javascript, and learn to solve problems with them(i.e. Promises , ES6, functional programming techniques.). Async/await的用途是简化使用promises 异步调用的操作,并对一组Promises 执行某些操作。 The purpose of async/await functions is to simplify the behavior of using promises synchronously and to perform some behavior on a group of Promises . 当今JavaScript的Promise规范可以追溯到2012年,从ES6时可以使用--然而Promises 并非从JavaScript社区诞生。 The current JavaScript Promise specifications date back to 2012 and available from ES6- however Promises were not invented by the JavaScript community. 现在JavaScript的Promise规范可以追溯到二〇一二年,从ES6时可以动用--不过Promises 并非从JavaScript社区诞生。 The current JavaScript Promise specifications date back to 2012 and available from ES6- however Promises were not invented by the JavaScript community.
展示更多例子
结果: 102 ,
时间: 0.0217
English
Bahasa indonesia
日本語
عربى
Български
বাংলা
Český
Dansk
Deutsch
Ελληνικά
Español
Suomi
Français
עִברִית
हिंदी
Hrvatski
Magyar
Italiano
Қазақ
한국어
മലയാളം
मराठी
Bahasa malay
Nederlands
Norsk
Polski
Português
Română
Русский
Slovenský
Slovenski
Српски
Svenska
தமிழ்
తెలుగు
ไทย
Tagalog
Turkce
Українська
اردو
Tiếng việt