File tree Expand file tree Collapse file tree 2 files changed +3
-3
lines changed Expand file tree Collapse file tree 2 files changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ asyncReadFile();
5959
6060(3)更广的适用性。
6161
62- ` co ` 模块约定,` yield ` 命令后面只能是 Thunk 函数或 Promise 对象,而` async ` 函数的` await ` 命令后面,可以是 Promise 对象和原始类型的值(数值、字符串和布尔值,但这时等同于同步操作 )。
62+ ` co ` 模块约定,` yield ` 命令后面只能是 Thunk 函数或 Promise 对象,而` async ` 函数的` await ` 命令后面,可以是 Promise 对象和原始类型的值(数值、字符串和布尔值,但这时会自动转成立即 resolved 的 Promise 对象 )。
6363
6464(4)返回值是 Promise。
6565
Original file line number Diff line number Diff line change @@ -251,7 +251,7 @@ getJSON("/post/1.json").then(
251251
252252## Promise.prototype.catch()
253253
254- ` Promise.prototype.catch ` 方法是` .then(null, rejection) ` 的别名,用于指定发生错误时的回调函数。
254+ ` Promise.prototype.catch ` 方法是` .then(null, rejection) ` 或 ` .then(undefined, rejection) ` 的别名,用于指定发生错误时的回调函数。
255255
256256``` javascript
257257getJSON (' /posts.json' ).then (function (posts ) {
@@ -993,7 +993,7 @@ try {
993993上面这样的写法就很笨拙了,这时就可以统一用` promise.catch() ` 捕获所有同步和异步的错误。
994994
995995``` javascript
996- Promise .try (database .users .get ({id: userId}))
996+ Promise .try (() => database .users .get ({id: userId}))
997997 .then (... )
998998 .catch (... )
999999```
You can’t perform that action at this time.
0 commit comments