The Observer Pattern
Last updated
Was this helpful?
Last updated
Was this helpful?
Observer Pattern is one of the behavioral design pattern. Observer design pattern is useful when you are interested in the state of an object and want to get notified whenever there is any change. In observer pattern, the object that watch on the state of another object are called Observer and the object that is being watched is called Subject.
Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
Encapsulate the core(or common or engine) components in a Subject abstraction, and the variable(or optional or user interface) components in an Observer hierarchy.
The "View" part of Model-View-Controller
https://www.journaldev.com/1739/observer-design-pattern-in-java
https://dzone.com/articles/observer-pattern-java
https://sourcemaking.com/design_patterns/observer