doc: create is this really how you use promises section
This commit is contained in:
1 parent
995aaec0dd
commit
ee9294ac51
1 file changed
+8
-1
@@ -238,4 +238,11 @@ let orderPizza = new Promise(orderExecutor);
|
||||
orderPizza
|
||||
.then(function () { console.log("Woohoo, let's eat!"); })
|
||||
.catch(function (value) { console.log(value); });
|
||||
```
|
||||
```
|
||||
|
||||
# 真的是这样使用Promise函数吗?
|
||||
- (现在)为了让事情变得更简单
|
||||
- 计时器和数字不是一个典型的/必要的Promise用例
|
||||
- Promise用于当我们不想停止主要的执行流程,但正在处理一个需要不确定的时间量任务时
|
||||
- 例子:从服务器请求信息
|
||||
- 如果服务器宕机了怎么办?如果返回的结果有错误怎么办?如果我的请求提供了不准确的信息,该怎么办?
|
||||
Reference in new issue
Block a user