What are event emitters?
Node.js core API is based on the asynchronous event-driven architecture in which certain kind of objects called emitters periodically emits events that cause listener objects to be called.
All objects that emit events are exposed on
eventEmitter.on() function that allows one or more functions to be attached to named events emitted by the object.
Event emitters allow us to not have a lot of if this happens then run this function and if this happens run this function repeating over and over again. Instead, we can just listen for an event.
Creating an emitter is essentially just an object full arrays and functions. But it is a very clean and a way to control the flow of events that happen in your code.<div class='sharedaddy sd-block sd-like jetpack-likes-widget-wrapper jetpack-likes-widget-unloaded' id='like-post-wrapper-155635758-442-5d077e4bd5c41' data-src='https://widgets.wp.com/likes/#blog_id=155635758&post_id=442&origin=trilamanila.com&obj_id=155635758-442-5d077e4bd5c41' data-name='like-post-frame-155635758-442-5d077e4bd5c41'><h3 class="sd-title">Like this:</h3><div class='likes-widget-placeholder post-likes-widget-placeholder' style='height: 55px;'><span class='button'><span>Like</span></span> <span class="loading">Loading...</span></div><span class='sd-text-color'></span><a class='sd-link-color'></a></div>