nodefn.call(Async2, nodefn.call(Async1)).ensure(done);
ここでは、Async2
実際に同期的に呼び出され、引数として Promise を使用します -解決するAsync1()
のを待ちません。Async1
それらをチェーンするには、使用する必要があります
nodefn.call(Async1).then(nodefn.lift(Async2)).ensure(done);
// which is equivalent to:
nodefn.call(Async1).then(function(result) {
return nodefn.call(Async2, result);
}).ensure(done);
2 つの呼び出しの間にいくつかのロジックを実行したい
次に、別の関数をチェーンに入れるか、チェーン内の関数の 1 つを変更する必要があります。
nodefn.call(Async1)
.then(function(res){return res+1;}) // return modified result
.then(nodefn.lift(Async2))
.ensure(done);
// or just
nodefn.call(Async1).then(function(res) {
res++; // do whatever you want
return nodefn.call(Async2, res);
}).ensure(done);