DEV Community

Abhijeet Jadhav
Abhijeet Jadhav

Posted on

Use of child process core node js package to handle asynchronous code execution.

This sample example of the use of the child process to handle the asynchronous code of node js. We all know we used promises and async-await javascript primitive method to handle the asynchronous code execution but I have found another way to handle asynchronous code without using promises. If you go through child.js I have used two functions to take some time to execution but we want two functions to process data for next synchronous process execution so I have used the fork process for execution in the background and wait for message event observer to get process execution data.

File: parent.js

Alt Text

File: child.js

Alt Text

I am trying to find out the logic if without using promises and async-await javascript primitive method can we execution synchronous. Kindly if any another example above scenarios.

Top comments (0)