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

Object-Oriented Programming (OOP)
A programming paradigm that organizes software design around objects containing data and behavior.
Event-Driven Architecture
A software design pattern where components communicate by producing and consuming events rather than direct method calls.
Twelve-Factor App
A methodology of twelve best practices for building modern, scalable, maintainable software-as-a-service applications.
API Design
The practice of designing application programming interfaces that are consistent, intuitive, and maintainable for developers to consume.
Code Smell
A surface indication in code that usually corresponds to a deeper problem in the system, suggesting the need for refactoring.
Regex (Regular Expression)
A sequence of characters that defines a search pattern, used for string matching, validation, and text manipulation.
View All Programming Concepts Terms โ†’