From the course: Node.js Essential Training

Unlock the full course today

Join today to access over 23,700 courses taught by industry experts.

Custom events with the EventEmitter

Custom events with the EventEmitter - Node.js Tutorial

From the course: Node.js Essential Training

Custom events with the EventEmitter

- Earlier we had created this collect answers function and what we want to do next with it is we want to break it down into different modules. The first thing we'll do is inside of the start folder we will create a new folder called lib. And this is going to be a library folder that will contain other functions that we can use in different places. So here we want to call this collect answers js. Collect answers js is going to be responsible for housing, this collect answers function. Which really requires several things. So we're going to start to break down this file. We'll cut everything from line 24 and up and drop it here into the collect answers file. The next thing we'll do, is we still want to import read line. We still want to create our interface. But we want to make this consumable by another file. So we're going to replace this function. We'll save module dot exports. We'll set this equal to our function and…

Contents