๐ŸŽ 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

Technical Debt
The implied cost of additional rework caused by choosing a quick solution now instead of a better approach that would take longer.
Event-Driven Architecture
A software design pattern where components communicate by producing and consuming events rather than direct method calls.
Recursion
A programming technique where a function calls itself to solve a problem by breaking it into smaller subproblems.
Algorithm
A step-by-step procedure for solving a problem or performing a computation, defined as a finite sequence of instructions.
Data Structure
A way of organizing and storing data in a computer so it can be accessed and modified efficiently.
Concurrency
The ability of a program to manage multiple tasks that can make progress during overlapping time periods.
View All Programming Concepts Terms โ†’