s*****w 发帖数: 1527 | |
l**********n 发帖数: 8443 | |
c*********e 发帖数: 16335 | 3 promise, async are for different purposes.
【在 s*****w 的大作中提到】 : 没有完全理解啊,这2种哪种好?
|
s*****w 发帖数: 1527 | 4
es7用啥新技术?promise没啦?
【在 l**********n 的大作中提到】 : 现在都用es7啦
|
s*****w 发帖数: 1527 | 5 主要是想做flow control。
比如一个batch file, 一行行命令一个个执行过去。
用2者有啥区别?
【在 c*********e 的大作中提到】 : promise, async are for different purposes.
|
l**********n 发帖数: 8443 | 6
【在 s*****w 的大作中提到】 : 主要是想做flow control。 : 比如一个batch file, 一行行命令一个个执行过去。 : 用2者有啥区别?
|
h**********c 发帖数: 4120 | 7 ...
要一杯python
...
循环两次,不要for,也不要while
...
中间也不要放if
...
免贵,属兔
...
2>=兔++您resolve了先生的goto的ipthon
【在 s*****w 的大作中提到】 : 没有完全理解啊,这2种哪种好?
|
h**********c 发帖数: 4120 | 8 ...
要一杯python
...
循环两次,不要for,也不要while
...
中间也不要放if
...
免贵,属兔
...
2>=兔++您resolve了先生的goto的ipthon
【在 s*****w 的大作中提到】 : 没有完全理解啊,这2种哪种好?
|
l**********n 发帖数: 8443 | 9 You can even do this ( using await in the return statement will turn the
function into an AsyncFunction)
【在 l**********n 的大作中提到】
|
s*****w 发帖数: 1527 | 10 谢大牛,学习一下去
【在 l**********n 的大作中提到】
|
|
|
c*********e 发帖数: 16335 | 11 promise主要是用于ajax取得response后的执行;
async就是异步了,不等ajax取得数据就行动。
【在 s*****w 的大作中提到】 : 主要是想做flow control。 : 比如一个batch file, 一行行命令一个个执行过去。 : 用2者有啥区别?
|
s*****w 发帖数: 1527 | 12 大牛,请教一下啊,记得async.waterfall是要等第一个执行结束,再做第二个的吧?
【在 c*********e 的大作中提到】 : promise主要是用于ajax取得response后的执行; : async就是异步了,不等ajax取得数据就行动。
|
c*********e 发帖数: 16335 | 13 2个的不同,在于出现error之後的处理方式:promise更灵活一些。
1. async.waterfall
if any of the tasks pass an error to their own callback, the next function
is not executed, and the main callback is immediately called with the error.
2. promise chaining
function myAsyncFunction(url) {
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.onload = () => resolve(xhr.responseText);
xhr.onerror = () => reject(xhr.statusText);
xhr.send();
});
});
【在 s*****w 的大作中提到】 : 大牛,请教一下啊,记得async.waterfall是要等第一个执行结束,再做第二个的吧?
|
s*****w 发帖数: 1527 | 14 多谢大牛,周末愉快!
error.
【在 c*********e 的大作中提到】 : 2个的不同,在于出现error之後的处理方式:promise更灵活一些。 : 1. async.waterfall : if any of the tasks pass an error to their own callback, the next function : is not executed, and the main callback is immediately called with the error. : 2. promise chaining : function myAsyncFunction(url) { : return new Promise((resolve, reject) => { : const xhr = new XMLHttpRequest(); : xhr.open("GET", url); : xhr.onload = () => resolve(xhr.responseText);
|
c*********e 发帖数: 16335 | 15 async.waterfall本质上是用的promise。
【在 s*****w 的大作中提到】 : 多谢大牛,周末愉快! : : error.
|