Search code examples
node.jswait

How to exit from function which is called using wait.for.function()


Due to application requirements i have to use wait.for.function()

var wait = require('wait-for-stuff'); 
function a(){
console.log("hello");
 return;
}

wait.for.function(a)
console.log('end')

using above way of calling the function..the wait.for.function() is waiting indefinetly..so any lines after wait.for.function(a) is not getting executed including the console statement after it.Can some one tell me how to exit from the function so that the lines after wait.for.function() gets executed.


Solution

  • It expects a callback.

    var wait = require('wait-for-stuff'); 
    function a(cb){
        console.log("hello");
        return cb();
    }
    
    wait.for.function(a)
    console.log('end')