Reading 16 Event Driven Applications - liz-kavalski-401-advanced-javascript/seattle-javascript-401n13 GitHub Wiki

Node Event Emitters Explained

  • Event-driven architecture in which certain kind of objects called emitters periodically emit events that cause listener objects to be called.
  • All objects that emit events are members of EventEmitter class. These objects expose an eventEmitter.on() function that allows one or more functions to be attached to named events emitted by the object.
  • 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.
  • The listener can be invoked only once using eventEmitter.once() method while every time the event is emitted using eventEmitter.on()
  • Code examples

Event Driven Programming

  • Event-Driven Programming is a logical pattern that we can choose to confine our programming within to avoid issues of complexity and collision.
  • Already using it. (calling an event i.e: click a button)
  • EventEmitter that allows us to get started incorporating Event-Driven Programming in our project right away.
  • Access the EventEmitter class through the events module.
  • Can be removed.
  • The Object Oriented approach promotes the idea that all behavior of an individual unit (or object) be handled from code within that unit.

To read more about for later.

Node.js - Event Emitter Node.js v12.8.0 Documentation