Observer Pattern and Pub/Sub
A pattern where one or more 'observers' subscribe to notifications from a 'subject,' decoupling the code that triggers events from the code that reacts to them.
The Observer pattern (and its close cousin, the publish/subscribe or 'pub/sub' pattern) defines a one-to-many relationship where a subject maintains a list of dependent observers and automatically notifies all of them whenever its own state changes, without needing to know anything specific about who those observers are or what they'll do with the notification. This is one of the most practically important patterns in JavaScript because it's the conceptual foundation underneath DOM event listeners, custom event systems, and reactive state libraries.
The Observer pattern is like a magazine subscription service: the publisher (subject) doesn't need to personally know each individual subscriber's reading habits or preferences — it just mails out the next issue to everyone currently on its subscriber list, and subscribers can join or cancel their subscription independently without the publisher needing to change anything about how it prints and distributes issues.