The short answer is yes, the way you usually deal with this on a node system is exactly the way you describe it.
node , . node-facebook-client ( npm, API- facebook)
console.log('start');
client.graphCall(path, params, method)(function(result) {
console.log('facebook returned');
});
console.log('end');
start
end
facebook returned
, , node ( ). , , node - . "" "facebook",
console.log('start');
client.graphCall(path, params, method)(function(result) {
console.log('facebook returned');
console.log('end');
});
, , , node. child_process.fork:
var cp = require('child_process');
var n = cp.fork(__dirname + '/sub.js');
n.on('message', function(m) {
console.log('PARENT got message:', m);
});
n.send({ hello: 'world' });
script, 'sub.js' :
process.on('message', function(m) {
console.log('CHILD got message:', m);
});
process.send({ foo: 'bar' });
send(), , .