
See Our team
Wondering how we keep quality?
Got unsolved questions? Ask Questions
GATE
GMAT
CBSE
NCERT
Career
Interview
Railway
UPSC
NID
NIFT-UG
NIFT-PG
PHP
AJAX
JavaScript
Node Js
Shell Script
Research
What are event emitters in NodeJS?
Give examples
As we have seen in the previous section, EventEmitter class lies in the events module. It is accessible via the following code −
When an EventEmitter instance faces any error, it emits an 'error' event. When a new listener is added, 'newListener' event is fired and when a listener is removed, 'removeListener' event is fired.
EventEmitter provides multiple properties like on and emit. on property is used to bind a function with the event and emit is used to fire an event.
You might like this video:Network and IP Address Watch more here
Watch more videos from this user Here
Learn how to upload a video over here
You might like this video:Data Flow on the Internet Watch more here
Watch more videos from this user Here
Learn how to upload a video over here
You might like this video:How eduladder works Watch more here
Watch more videos from this user Here
Learn how to upload a video over here
Node.js core API is based on asynchronous event-driven architecture in which certain kind of objects called emitters periodically emit events that cause listener objects to be called.
When the EventEmitter object emits an event, all of the functions attached to that specific event are called synchronously. All values returned by the called listeners are ignored and will be discarded.
Consider the following example:
You might like this video:Javascript Watch more here
Watch more videos from this user Here
Learn how to upload a video over here
We made eduladder by keeping the ideology of building a supermarket of all the educational material available under one roof. We are doing it with the help of individual contributors like you, interns and employees. So the resources you are looking for can be easily available and accessible also with the freedom of remix reuse and reshare our content under the terms of creative commons license with attribution required close.
You can also contribute to our vision of "Helping student to pass any exams" with these. Answer a question: You can answer the questions not yet answered in eduladder.How to answer a question Career: Work or do your internship with us.Work with us Create a video: You can teach anything and everything each video should be less than five minutes should cover the idea less than five min.How to upload a video on eduladder