相关疑难解决方法(0)

promise.then.then与promise.then之间有区别吗?promise.then

我想知道下面两个有区别吗?

  1. aPromiseObj.then(fn1).then(fn2).catch(fn3);
  2. aPromiseObj.then(fn1); aPromiseObj.then(fn2); aPromiseObj.catch(fn3);

工作流程会改变吗?

ps:我处于有条不紊的环境中,尽管我想从更广泛的角度来思考这个问题.

promise angularjs

13
推荐指数
1
解决办法
6127
查看次数

在系列中执行本机js promise

我必须为数组中的每个项目调用一些异步任务的承诺,但我想连续执行这些.

Promise.all仅用于具有合并promise列表的新promise,但它不会按顺序调用它们.

如何使用标准的promise api来实现这一点,而没有第三方库,如Q,bluebird ....

javascript node.js promise

8
推荐指数
1
解决办法
1249
查看次数

理解javascript承诺; 堆叠和链接

我一直遇到javascript承诺的几个问题,特别是堆叠链.

谁能向我解释这些不同实现之间的差异(如果有的话)?

实施1

var serverSidePromiseChain;
serverSidePromiseChain = async().then(function(response) {
    console.log('1', response);
    return response;
}).then(function(response) {
    console.log('2', response);
    return true;
}).then(function(response) {
    console.log('3', response); // response expected to be 'true'
    return async3();
}).then(function(response) {
    console.log('4', response);
    return async4();
})
Run Code Online (Sandbox Code Playgroud)

实施2

var serverSidePromiseChain;
serverSidePromiseChain = async().then(function(response) {
    console.log('1', response);
    return response;
});

serverSidePromiseChain.then(function(response) {
    console.log('2', response);
    return true;
})
serverSidePromiseChain.then(function(response) {
    console.log('3', response); // response expected to be 'true'
    return async3();
})
serverSidePromiseChain.then(function(response) {
    console.log('4', response);
    return async4();
})
Run Code Online (Sandbox Code Playgroud)

实施3

var serverSidePromiseChain; …
Run Code Online (Sandbox Code Playgroud)

javascript promise chain

5
推荐指数
1
解决办法
7113
查看次数

标签 统计

promise ×3

javascript ×2

angularjs ×1

chain ×1

node.js ×1