Class-17 Reading: TCP Servers
Class-17 Reading: TCP Servers
Table of Contents
Reading, Research, and Discussion
- The server listening on port 3000, that is an event listener waiting for HTTP requests. Once those requests hit routers, they fire off callbacks , or event handlers.
- When a specific route it hit, it fire off callback functions.
2. Why are events sometimes better than asynchronous actions with callbacks?
- Callbacks are an additional step, and events are fired off upon the event they are listening for. So there can be a potential delay, also adding to the call stack more than necessary.
3. What does an EventEmitter instance do?
- It keeps track of all new listeners and removed listenings within the instance. Manages state.
4. When is a program’s call stack, event queue, and event loop active?
- Whenever our code is ran, the event loop will check the call stack if its empty. The event loop is active, and once the stack is empty , all done.
Vocabulary Terms
Observer Pattern
:
- def: The observer pattern is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods.
- Resource: webdevstudios.com
Listener
:
- def: These are the objects that want to know when the subject has changed. In our case, these will be the page elements that need to update when the application state changes.
- Resource: webdevstudios.com
Event Handler
:
- def: A function or method containing program statements that are executed in response to an event.
Event Driven Programming
:
- def: Event Driving programming is a programming paradigm in which the flow of programming is determined by events such as user actions.
Event Loop
:
- def: A programming construct or design pattern that waits for and dispatches events or messages in a program.
Event Queue
:
- def: An event queue is a repository where events from an application are held prior to being processed by a receiving program or system
Call Stack
:
- def: A call stack is a mechanism for an interpreter (like the JavaScript interpreter in a web browser) to keep track of its place in a script that calls multiple functions — what function is currently being run and what functions are called from within that function, etc.
Emit/Raise/Trigger
:
- def: Emitting events, raising events, and trigger events are all connected on events.EventEmitter
Subscribe
:
- def: An application that registers itself with the desired topic in order to receive the appropriate messages
database
:
- def: a structured set of data held in a computer, especially one that is accessible in various ways.