[Node.js] Build a clean process manager
In this article, I’ll demonstrate how to buid a simple and maintainable process manager for Node.js, leveraging its Event Loop. The main idea is have a core processor that will be able to run a serie of tasks, in a synchronous way. As you may know, Javascript is by essence an asynchronous language. Let take simple example : As the execution flow is asynchroneous, the result variable will not be valued before the crawling method ends, and the usage of the variable will occurs before its valuation The standard solution in javascript to handle this issue is to use a callback method : Callbacks are really handy, but what happen if if I have a process with several tasks in it? Yes, we just felt into the Callback Hell! The main issue with the nested callback is that your code has a lack of readability and flexibility. It’s quite difficult to understand what the code is meant to do. And if you have to modify the process, you’ll have to rethink the whole process. ...