Skip to content

加入注意事项(已增添到英文版) #569

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

Merged
merged 2 commits into from
Jan 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions 1-js/11-async/02-promise-basics/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ promise.then(alert); // 完成!(现在显示)
```

这对于有时需要时间而且有时要立即完成的任务来说非常方便。确保处理器在两种情况下都能够运行。

需要注意的是:这和真实生活中的”订阅列表“场景不同,并且更有效能:如果歌手已经发行了一首歌之后,人们才去注册订阅列表,这样很可能收不到那首歌。真实生活中,订阅必须发生在事件之前。

Promise 则更加灵活些。我们可以在任意时间添加处理器:如果结果已经在了,我们的处理器便会立即拿到这个结果。
````

````smart header="`.then/catch` 的处理器总是异步的"
Expand Down