Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

node js - excecute a child process and exchange message to and from

// parent.js
const chPro = require('child_process');
const chFork = chPro.fork('child.js');
chFork.on('message', (msg) => {
  console.log('Message from child process => ', msg);
});
chFork.send({ hello: 'world' });

// child.js
process.on('message', (msg) => {
  console.log('Message from the parent => ', msg);
});

let counter = 0;
setInterval(() => {
  process.send({ counter: counter++ });
}, 1000);
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery callback functions 
Javascript :: json syntax 
Javascript :: suitescript get lineitemcount 
Javascript :: ex: javascript Executor 
Javascript :: javascript get days difference between two dates 
Javascript :: at runtime.exports.handler aws lambda 
Javascript :: prevent js execution in elementor 
Javascript :: javasrcipt jpg resize 
Javascript :: javascript read all cookies 
Javascript :: adding transition to collapse button js 
Javascript :: phaser place on rectangle shift 
Javascript :: phaser chained animation 
Javascript :: phaser show animation play through js 
Javascript :: refresh secounds 
Javascript :: template literal inside a key in react 
Javascript :: Move capital letters to the beginning 
Javascript :: hot reload nestjs 
Javascript :: mongo db backup node js daily 
Javascript :: javascript array includes 
Javascript :: javascript static methods 
Javascript :: mongoose schema example 
Javascript :: react native toggle button with text 
Javascript :: mongodb find and update array item by id 
Javascript :: multer 
Javascript :: mongoose get method 
Javascript :: javascript autocomplete 
Javascript :: function with .map javascript 
Javascript :: how to store variable in local storage angualur 
Javascript :: how to detect a section is visible in jquery 
Javascript :: requestanimationframe in javascript 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =