Observer Design Pattern
Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
Last updated
Was this helpful?
Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
Last updated
Was this helpful?
In this pattern, we call the publisher the SUBJECT and the subscribers the OBSERVER
Strive for loosely coupled designs between objects that interact
Loosely couples designs allow us to build a flexible OO system that can handle change because they minimize the interdependency between objects.
When you need many other objects to receive the update when another object changes
Loose coupling - Subject ( Publisher ) doesn't need to know about the Observer ( Subscriber ).
You can establish relations between objects at runtime.
Changes to either the subject or an observer will not affect the other.
Subject ( Publisher ) may send the updates that don't matter to the observer ( Subscriber ).