๐ŸŽ New User? Get 20% off your first purchase with code NEWUSER20 ยท โšก Instant download ยท ๐Ÿ”’ Secure checkout Register Now โ†’
Menu

Categories

Programming Concepts Intermediate

What is Observer Pattern?

A design pattern where an object (subject) maintains a list of dependents (observers) that are notified automatically of state changes.

The Observer pattern establishes a one-to-many dependency between objects. When the subject changes state, all registered observers are notified and updated automatically. This decouples the subject from its observers โ€” the subject doesn't need to know what the observers do with the notification. Examples include event listeners in JavaScript (addEventListener), pub/sub messaging, reactive streams (RxJS), and MVC frameworks where views observe model changes. Variants include push (subject sends data with notification) and pull (observers query the subject after notification). The pattern is fundamental to reactive programming and event-driven systems.

Related Terms

Linked List
A linear data structure where elements are stored in nodes, each containing data and a pointer to the next node in the sequence.
Version Control
A system that records changes to files over time, allowing you to recall specific versions, collaborate, and track history.
Immutable Object
An object whose state cannot be modified after creation, providing thread safety and predictable behavior in concurrent systems.
Unit Testing
Testing individual components or functions of a program in isolation to verify they work correctly.
Singleton Pattern
A design pattern that restricts a class to a single instance and provides a global point of access to that instance.
Clean Code
Code that is easy to read, understand, and maintain โ€” following consistent conventions, meaningful naming, and single-responsibility functions.
View All Programming Concepts Terms โ†’