-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
translation/06-async/03-promise-chaining #255
translation/06-async/03-promise-chaining #255
Conversation
resolve #242 |
@leviding 校对认领 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
写得不错 👍,只是有些地方可以改得再通顺一点,比如说加标点符号,例如:逗号。
@@ -1,12 +1,12 @@ | |||
# Promise: then versus catch | |||
# Promise: then VS catch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VS -> 对比
会比较好
|
||
Are these code fragments equal? In other words, do they behave the same way in any circumstances, for any handler functions? | ||
这两段代码片段是否相等?换句话说,对于任何处理函数在任何情况下的行为方式是否相同? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
换句话说,对于任何处理函数在任何情况下,它们的行为方式是否相同?
|
||
```js | ||
promise.then(f1, f2); | ||
``` | ||
|
||
Versus; | ||
VS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
对比的代码:
@@ -1,6 +1,6 @@ | |||
# Error in setTimeout | |||
# setTimeout 中的 error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setTimeout 中的错误
|
||
How do you think, does the `.catch` trigger? Explain your answer? | ||
你认为 `.catch` 会不会触发?请解释你的回答? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
会不会请解释一下。
比较好?
@@ -320,13 +318,13 @@ fetch('/article/promise-chaining/user.json') | |||
.then(githubUser => alert(`Finished showing ${githubUser.name}`)); | |||
``` | |||
|
|||
Now right after `setTimeout` runs `img.remove()`, it calls `resolve(githubUser)`, thus passing the control to the next `.then` in the chain and passing forward the user data. | |||
现在在 `setTimeout` 后运行 `img.remove()`,然后调用 `resolve(githubUser)`,这样链中的控制流程走到下一个 `.then` 并传入用户数据。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
现在在 -> 现在 / 现在,在
|
||
As a rule, an asynchronous action should always return a promise. | ||
通常一个异步动作总是需要返回一个 promise。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
作为一个规律(好的习惯)
一个异步动作应该永远返回一个 promise。
|
||
That makes possible to plan actions after it. Even if we don't plan to extend the chain now, we may need it later. | ||
这就让规划下一步动作成为可能。虽然现在我们没打算扩展链,不过我们可能在后面需要它。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这让规划下一步动作成为可能。虽然现在我们没打算扩展链,我们可能在日后需要它。
@@ -377,18 +375,18 @@ fetch('https://no-such-server.blabla') // rejects | |||
.catch(err => alert(err)) // TypeError: failed to fetch (the text may vary) | |||
``` | |||
|
|||
Or, maybe, everything is all right with the server, but the response is not a valid JSON: | |||
或者是,服务器的一切都很好,但响应不是有效的 JSON: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
或者,有可能,
@@ -485,49 +483,50 @@ new Promise(function(resolve, reject) { | |||
}).then(() => alert("Next successful handler runs")); | |||
``` | |||
|
|||
Here the `.catch` block finishes normally. So the next successful handler is called. Or it could return something, that would be the same. | |||
在这里,`.catch` 块正常结束。所以会调用下一个成功处理程序。或者它可以返回一些东西,这和之前的流程相同。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在这里,.catch
块正常结束,然后调用下一个成功处理程序。或者它可以返回一些东西,这和之前的流程相同。
@leviding 校对完成 |
已根据校对建议修改完毕,@calpa 校对地很用心仔细,点赞。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good @leviding
校对 4 分,翻译 11 分,辛苦了。 |
翻译完毕,不好意思由于国庆超了几天。