#stubborndevelopers
In this video we will learn that what is the Events Module in Node.js and how we can use it. Then we will learn that how we can handle Events in Node.js with EventEmitter class.
What is an EventEmitter?
The EventEmitter class is a built-in class that resides in the events module of Node.js
Creating EventEmitters
We will create an EventEmitter. This can be done either via creating an instance of the class itself, or by implementing it through a custom class and then creating an instance of that class.
Creating an EventEmitter Object
We will create simple event-emitting object that will emit an event that contains information about the application's uptime, every second.
Firstly, import the EventEmitter class from the events modules:
const EventEmitter = require('events');
Secondly, create object of EventEmitter class:
const myEmitter = new EventEmitter();
*********** Node.JS Tutorial in English 2021 Playlist ***********
• how to install node js
*********** React.JS Tutorial in Hindi 2021 Playlist ***********
• react js introduction in hindi