Let's say, when your application starts, you are checking the connection to the database and/or doing some other operations which are in different files and you want to inform your app.js file about the connection or pass the information regarding certain operation in multiple files.
You can send an event across the app and wherever you are listening for that event, you can then perform some other operation like retry if db connection fails.
This is useful for communicating between multiple files, passing data between two js files etc.
Based on some action you can fire the particular event emitter just say on click certain button you want to fire some event or some code then you can use eventemitter I guess.
What are some practical use of event emitters?
Let's say, when your application starts, you are checking the connection to the database and/or doing some other operations which are in different files and you want to inform your app.js file about the connection or pass the information regarding certain operation in multiple files.
You can send an event across the app and wherever you are listening for that event, you can then perform some other operation like retry if db connection fails.
This is useful for communicating between multiple files, passing data between two js files etc.
Do you have any example Express project using event emitter?
this is effectively what socket.io does.
this snippet is from pdfmake which creates a buffer and stringBase64
Based on some action you can fire the particular event emitter just say on click certain button you want to fire some event or some code then you can use eventemitter I guess.
To drive fellow developers crazy when trying to debug
Home automation would be one. To extend the example from the article - car on, open garage door and turn on the lights.