When to use eventEmitter in Node js?

I am learning new concept in node js that is event but i could not find where i should use this,I want any real scenario I could not find any article or blog on this.

var events = require('events');
var eventEmitter = new events.EventEmitter();

//Create an event handler:
var myEventHandler = function () {
  console.log('I hear a scream!');

//Assign the event handler to an event:
eventEmitter.on('scream', myEventHandler);
eventEmitter.on('test', function(){
    console.log("Testing event");

//Fire the 'scream' event:

I can achive same thing by simple call function like myEvenHandler()?

76 thoughts on “When to use eventEmitter in Node js?”

  1. Hi, Neat post. There is a problem together with your site in web explorer,
    could test this? IE nonetheless is the marketplace leader and a huge element of
    other folks will omit your magnificent writing because of this

  2. I am really enjoying the theme/design of your blog.
    Do you ever run into any web browser compatibility issues?
    A small number of my blog visitors have complained about my blog not operating correctly in Explorer but looks great in Chrome.
    Do you have any suggestions to help fix this problem?

  3. It’s the best time to make some plans for the future and it’s time to be happy.

    I have read this post and if I could I desire to suggest you some interesting things or suggestions.

    Maybe you could write next articles referring to this article.
    I desire to read more things about it!

  4. I do not even know how I ended up here, but I thought this post was great.

    I don’t know who you are but certainly you are going to a famous blogger if
    you aren’t already 😉 Cheers!

  5. Definitely believe that that you said. Your favorite reason seemed to be on the internet the simplest factor
    to take into account of. I say to you, I certainly get annoyed whilst
    folks consider issues that they just do not recognize about.
    You managed to hit the nail upon the highest as smartly as defined out the entire thing with no need side effect
    , other folks could take a signal. Will probably be again to get more.
    Thanks scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis surgery


Leave a Comment