mirror of
https://github.com/ruanyf/es6tutorial.git
synced 2025-05-25 03:02:21 +00:00
Fix coding style in docs/async.md
这一篇由于引入了其他源码,所以我改动比较保守,只改了明显可以改进的地方
This commit is contained in:
parent
307932e155
commit
e8748dfbcd
@ -498,7 +498,7 @@ co函数返回一个Promise对象,因此可以用then方法添加回调函数
|
|||||||
```javascript
|
```javascript
|
||||||
co(gen).then(function (){
|
co(gen).then(function (){
|
||||||
console.log('Generator 函数执行完成');
|
console.log('Generator 函数执行完成');
|
||||||
})
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
上面代码中,等到Generator函数执行结束,就会输出一行提示。
|
上面代码中,等到Generator函数执行结束,就会输出一行提示。
|
||||||
@ -552,7 +552,7 @@ g.next().value.then(function(data){
|
|||||||
g.next(data).value.then(function(data){
|
g.next(data).value.then(function(data){
|
||||||
g.next(data);
|
g.next(data);
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
手动执行其实就是用then方法,层层添加回调函数。理解了这一点,就可以写出一个自动执行器。
|
手动执行其实就是用then方法,层层添加回调函数。理解了这一点,就可以写出一个自动执行器。
|
||||||
@ -863,7 +863,7 @@ async function foo() {}
|
|||||||
const foo = async function () {};
|
const foo = async function () {};
|
||||||
|
|
||||||
// 对象的方法
|
// 对象的方法
|
||||||
let obj = { async foo() {} }
|
let obj = { async foo() {} };
|
||||||
|
|
||||||
// 箭头函数
|
// 箭头函数
|
||||||
const foo = async () => {};
|
const foo = async () => {};
|
||||||
@ -1000,7 +1000,7 @@ function chainAnimationsPromise(elem, animations) {
|
|||||||
p = p.then(function(val) {
|
p = p.then(function(val) {
|
||||||
ret = val;
|
ret = val;
|
||||||
return anim(elem);
|
return anim(elem);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回一个部署了错误捕捉机制的Promise
|
// 返回一个部署了错误捕捉机制的Promise
|
||||||
|
Loading…
x
Reference in New Issue
Block a user