Skip to content

NodeJS module,simple wrapper for child_process.fork() to send messages with callbacks.

License

Notifications You must be signed in to change notification settings

xdenser/node-childWithCallbacks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wrapper for NodeJS child_process.fork().

Adds callback parameter to send function. So you may receive direct callback from child process on your message. Usage is obvious from sample.

In parent:

var 
   ChildProcess = require('../childWithCallbacks').child,
   child = new ChildProcess(__dirname + '/child.js');
   
  
  child.send('Wait10sec',null,function(err,data){
     console.log('Received '+data); 
  });

In child.js:

 var 
   parent = require('../childWithCallbacks').getParent();
   
   
   parent.on('message',function(message,handle,cb){
      console.log('Received '+message);
      setTimeout(function(){
          cb(null,'Done');
          process.exit();
      },10000); 
   });

About

NodeJS module,simple wrapper for child_process.fork() to send messages with callbacks.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published