Don’t miss out when something interesting happens!
We’ve got a pattern that keeps your objects in the know when something they might care about happens. Objects can even decide at runtime whether they want to be kept informed. The Observer Pattern is one of the most heavily used patterns in the JDK, and it’s incredibly useful.Head First Design Patterns
The Observer Pattern defines a one-to-many dependency between objects so that when one object changes state, all of its dependents are notified and updated automatically.
Check out the source: https://github.com/pintalubaf/design-patterns/tree/master/src/observer