Suppose I have the following code:
foo();
function foo() {
func1("bla", function() {
console.log("done!");
});
}
function func1(value,callback) {
process.nextTick(callback);
}
Will the function above will be totally async ? Or should I use this foo function? :
function foo() {
process.nextTick(function() {
func1("bla", function() {
console.log("done!");
});
}
Actually my question is if the parent blocks the child process from being Async ?
The first option is going to be "async" in the sense that node might do other things before calling the callback method.
There is no need to call the second method. As soon as your foo function finishes and any parent callers of foo finish node will start doing other work, which eventually will be the work registered by nextTick.