Exercise 3.3 - A simple modification
The key thing here is the process.nextTick()
method, as explained in the book.
You can not call the on
method from a function that returns an event emitter stright away, unless a setInterval
or setTimeout
it's used, basically relying on the next round of the event loop, so process.nextTick()
is quite usefull here.
Using npm
$ npm start_3_3
Using yarn:
$ yarn start_3_3