$> git checkout observer
Intent
Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.1
Applications
The observer pattern is used when you want objects to react to specific events on a subject object. When the subject changes, it notifies observers. This is one of the most popular patterns I will cover. In fact, PHP already has built-in interfaces for the observer pattern: SplSubject 2 and SplObserver 3.
Abstract Structure
Figure 22-1. Abstract structure
SplSubjectis an abstract class or interface. When using ...