English 中文(简体)
node.js async. 序列无效
原标题:node.js async.series not working

这段代码直接摘自此例:https://github.com/caolan/async#seriestasks-callback

var async = require("async");
async.series([
    function() { console.log("a"); },
    function() { console.log("b"); }
], function(err, results){
    console.log(err);
    console.log(results);
});

印刷“a”之后就停止了。

是最新的合成模块的窃听器 还是我的用法有问题?

最佳回答

在传递到 Async 的数组中提供的函数。 序列需要接受一个回调参数, 函数在任务完成时会调用该参数。 所以, 您想要这样做 :

async.series([
    function(callback){ 
        console.log("a"); 
        callback();
    },
    function(callback){ 
        console.log("b");
        callback();
    }
]...
问题回答

暂无回答




相关问题
Asynchronous data loading in Entity-Framework?

Did anyone hear about asynchronous executing of an EF query? I want my items control to be filled right when the form loads and the user should be able to view the list while the rest of the items ...

Does PHP support asynchronous programming?

I m new to PHP. I am familiar with ASP.NET which support asynchronous programming. That is, if one request needs to do some I/O job. It is suggested to program the web page with BeginProcess/...

How to cancel an asynchronous call?

How to cancel an asynchronous call? The .NET APM doesn t seem to support this operation. I have the following loop in my code which spawns multiple threads on the ThreadPool. When I click a button on ...

What can cause select to block in Python?

Here s a snippet of code I m using in a loop: while True: print loop rlist, wlist, xlist = select.select(readers, [], [], TIMEOUT) print selected # do stuff At a certain point, ...

热门标签