Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/419.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 链接承诺和传递价值的简明方法_Javascript_Promise_Bluebird - Fatal编程技术网

Javascript 链接承诺和传递价值的简明方法

Javascript 链接承诺和传递价值的简明方法,javascript,promise,bluebird,Javascript,Promise,Bluebird,蓝鸟承诺最简洁的写作方式是什么: return someFunc().then(function(result) { return otherFunc(result).then(function(foo) { ... }); }); 我看到了一些util函数,如result(),但并不完全清楚我将如何使用它。基本上,我需要调用第二个函数,同时将第一个函数的结果作为参数传递。或者这是最简洁的吗?您可以这样简化它: return someFunc() .then(otherFunc

蓝鸟承诺最简洁的写作方式是什么:

return someFunc().then(function(result) {
  return otherFunc(result).then(function(foo) {
    ...
  });
});

我看到了一些util函数,如
result()
,但并不完全清楚我将如何使用它。基本上,我需要调用第二个函数,同时将第一个函数的结果作为参数传递。或者这是最简洁的吗?

您可以这样简化它:

return someFunc()
.then(otherFunc)
.then(function(foo) {
    return foo; // assuming you do more here...
});
我希望这不是您的全部代码,否则最后一个带有
return
的函数将是无用的,整个函数将与

return someFunc().then(otherFunc);

您可以这样简化它:

return someFunc()
.then(otherFunc)
.then(function(foo) {
    return foo; // assuming you do more here...
});
我希望这不是您的全部代码,否则最后一个带有
return
的函数将是无用的,整个函数将与

return someFunc().then(otherFunc);

您可以这样简化它:

return someFunc()
.then(otherFunc)
.then(function(foo) {
    return foo; // assuming you do more here...
});
我希望这不是您的全部代码,否则最后一个带有
return
的函数将是无用的,整个函数将与

return someFunc().then(otherFunc);

您可以这样简化它:

return someFunc()
.then(otherFunc)
.then(function(foo) {
    return foo; // assuming you do more here...
});
我希望这不是您的全部代码,否则最后一个带有
return
的函数将是无用的,整个函数将与

return someFunc().then(otherFunc);
.then(函数(foo){returnfoo;})是多余的

举个例子,这就是你所需要的

return someFunc().then(otherFunc);
.then(函数(foo){returnfoo;})是多余的

举个例子,这就是你所需要的

return someFunc().then(otherFunc);
.then(函数(foo){returnfoo;})是多余的

举个例子,这就是你所需要的

return someFunc().then(otherFunc);
.then(函数(foo){returnfoo;})是多余的

举个例子,这就是你所需要的

return someFunc().then(otherFunc);

这只是一个例子。我对链接感兴趣,同时将结果传递为arguments@Yashua好的,然后给我们一个例子,实际展示你想要做什么。这只是个例子。我对链接感兴趣,同时将结果传递为arguments@Yashua好的,然后给我们一个例子,实际展示你想要做什么。这只是个例子。我对链接感兴趣,同时将结果传递为arguments@Yashua好的,然后给我们一个例子,实际展示你想要做什么。这只是个例子。我对链接感兴趣,同时将结果传递为arguments@Yashua好的,然后给我们一个例子,实际显示你想要做什么。不太管用。我想我需要绑定-有没有一种方法可以绑定自动绑定,或者我需要为所有调用都绑定?在您展示的示例中没有理由绑定。不太管用。我想我需要绑定-有没有一种方法可以绑定自动绑定,或者我需要为所有调用都绑定?在您展示的示例中没有理由绑定。不太管用。我想我需要绑定-有没有一种方法可以绑定自动绑定,或者我需要为所有调用都绑定?在您展示的示例中没有理由绑定。不太管用。我想我需要绑定-有没有一种方法可以绑定自动绑定,或者我需要为所有调用绑定自动绑定?在您展示的示例中,没有理由绑定。