由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - angular Q: promise chain vs async waterfall
相关主题
node promise发出reject之后,是不是只能hit catch block ?看了一下C#的async await
node.js, express, sails, angularjs在一起做project,折磨人啊学了这么多语言发现还是coffeescript最好用
为什么需要node.js waterfall,而不是直接call python script看看大牛们为什么都远离.net
同步编程真郁闷这年头async IO成了流行了
尼玛 callback 真是反人类不要小看js
JQuery (转载)多线程,异步,并发冲突,fp和其它
Angular难题:angular.js:12477 SyntaxError: Unexpected token >真正对异步有需求的应该是游戏类服务器
asynchronous vs non-blocking用node怎么把多个mysql query 的结果合起来
相关话题的讨论汇总
话题: promise话题: async话题: waterfall话题: angular话题: chain
进入Programming版参与讨论
1 (共1页)
s*****w
发帖数: 1527
1
没有完全理解啊,这2种哪种好?
l**********n
发帖数: 8443
2
现在都用es7啦
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 的大作中提到】

相关主题
JQuery (转载)看了一下C#的async await
Angular难题:angular.js:12477 SyntaxError: Unexpected token >学了这么多语言发现还是coffeescript最好用
asynchronous vs non-blocking看看大牛们为什么都远离.net
进入Programming版参与讨论
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.

1 (共1页)
进入Programming版参与讨论
相关主题
用node怎么把多个mysql query 的结果合起来尼玛 callback 真是反人类
node 求算法JQuery (转载)
node.js child process: 怎样保证1个命令执行完了再执行下一个?Angular难题:angular.js:12477 SyntaxError: Unexpected token >
问个 rxjava 的问题asynchronous vs non-blocking
node promise发出reject之后,是不是只能hit catch block ?看了一下C#的async await
node.js, express, sails, angularjs在一起做project,折磨人啊学了这么多语言发现还是coffeescript最好用
为什么需要node.js waterfall,而不是直接call python script看看大牛们为什么都远离.net
同步编程真郁闷这年头async IO成了流行了
相关话题的讨论汇总
话题: promise话题: async话题: waterfall话题: angular话题: chain