How could I assign value to a global variable from async.waterfall
that is inside of setTimeout
?
Here is a part of my code:
var theVar = null;
setTimeout(function () {
async.waterfall([
function (next) {
var thedata = 1;
next(null,thedata);
},
function (thedata,next) {
if (thedata === 1) {
theVar = 2;
}
theVar = 3;
next();
], function (err, result) {
});
}, theVar * 1000); //theVar is timeout here.
So, basically, I want to set global variable from within async.waterfall
. That variable theVar
will then be the timeout in setTimeout
. Now theVar
is always null
.