Reading 15 - morgan-401-advanced-javascript/seattle-javascript-401n14 GitHub Wiki
Read
Node Event Emitters Explained
- 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.
- By default, all listeners attached to a particular event object are called by the EventListener object synchronously in the order in which they are registered or attached to the event object.
Event Driven Programming
-
For the most recognizable example of Event-Driven Programming for people at any level of programming skill, we’ll turn to our old friend The Web Browser.
-
Every time you interact with a webpage through it’s user interface, an event is happening. When you click a button a click event is triggered. When you press a key a keydown event is triggered. These events have associated functions that, when triggered, are executed to make a change to the user interface in some way.
-
Event-Driven Programming makes use of the following concepts:
-
An Event Handler is a callback function that will be called when an event is triggered.
-
A Main Loop listens for event triggers and calls the associated event handler for that event.
Bookmark
Node Event Emitter
Node docs: events
Vocab
Event-Driven Programming In computer programming, event-driven programming is a programming paradigm in which the flow of the program is determined by events such as user actions (mouse clicks, key presses), sensor outputs, or messages from other programs or threads. Event-driven programming is the dominant paradigm used in graphical user interfaces and other applications (e.g., JavaScript web applications) that are centered on performing certain actions in response to user input. This is also true of programming for device drivers (e.g., P in USB device driver stacks[1]).