From 95be1ee5391cfe4aa93d27843782d2ed96a28ddf Mon Sep 17 00:00:00 2001 From: tactonbishop Date: Wed, 20 Jul 2022 19:30:04 +0100 Subject: [PATCH] Last Sync: 2022-07-20 19:30:04 --- Programming_Languages/NodeJS/Modules/Core/events.md | 6 ++++-- markdown-styles.css | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Programming_Languages/NodeJS/Modules/Core/events.md b/Programming_Languages/NodeJS/Modules/Core/events.md index 9110c4e..6074f68 100644 --- a/Programming_Languages/NodeJS/Modules/Core/events.md +++ b/Programming_Languages/NodeJS/Modules/Core/events.md @@ -5,10 +5,12 @@ tags: - node-js - node-modules --- +# `events` module +In most case you won't interact with the `events` module directly since other modules and third-party modules are abstractions on top of this base-layer. For instance the `http` module is using events under the hood to handle requests and responses. -* Much of the NodeJS core is built around an [asynchronous event-driven architecture](Single-threaded%20asynchronous%20architecture.md) in which certain kinds of objects (called "emitters") emit named events that cause `Function` objects ("listeners") to be called. -* For example: a `fs.ReadStream` emits an event when the file is opened +Another way of putting this is to say that all events in Node inherit from the `EventEmitter` constructor, which is the class you instantiate to create a new event. At bottom everything in Node is an event with a callback, created via event emitters. +Because Node's runtime is [event-driven](/Programming_Languages/NodeJS/Architecture/Event_loop.md), it is event-emitter cycles that are being processed by the Event Loop, although you may know them as `fs` or `http` (etc) events. The call stack that the Event Loop works through is just a series of event emissions and their associated callbacks. ## Event Emitters * All objects that emit events are instances of the `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. diff --git a/markdown-styles.css b/markdown-styles.css index 0c1c27d..8c89810 100644 --- a/markdown-styles.css +++ b/markdown-styles.css @@ -1,6 +1,6 @@ -h1, h2, h3, h4, h5, h6, p { +/* h1, h2, h3, h4, h5, h6, p { font-family: 'Inter'; -} +} */ pre, code { font-family: 'JetBrains Mono' !important;