Computer scienceBackendNode.jsCore ConceptsInternal modulesEventsEvents module basics

Intro to events module

Inner emitter

Report a typo

Here is a code snippet that listens for the main and initial events. You should emit the main event inside the initial event handler so that the appropriate line is printed to the console.

Write a program in JavaScript
const EventEmitter = require('events'); //do not change this line!

const emitter = new EventEmitter();

emitter.on('main', () => {
console.log('It is main event!')
})

emitter.on('initial', (eventName) => {
/* your code */
});

emitter.emit('initial', /* your code */);
___

Create a free account to access the full topic