Closed iamerikjolson closed 10 years ago
wait for requires a standard async function, with callback(err,data) as last parameter. setTimeout do not callback. you do not get 'fn end' because the function at setTimeout never call back.
try this (not tested)
var wait = require('wait.for');
function standardAsync(param, callback){
setTimeout( function(){
console.log(param);
callback(null,param);
}, 5000);
};
function testFunction(){
console.log('fn start');
wait.for(standardAsync,'test');
console.log('fn end');
};
console.log('app start');
wait.launchFiber(testFunction);
console.log('after launch');
I've read and re-read your github documentation, and still can't get node to wait. What am I doing wrong?
var wait = require('wait.for'), testFunction = function(){ console.log('fn start'); wait.for(setTimeout, function(){}, 5000); console.log('fn end');
};
console.log('app start'); wait.launchFiber(testFunction); console.log('app end');
The expected outcome is:
Instead what I get is