Observer Pattern
The Observer pattern allows objects to subscribe to events.
Example
Section titled “Example”class Subject {
private array $observers = [];
public function attach($observer) { $this->observers[] = $observer; }
public function notify() { foreach ($this->observers as $observer) { $observer->update(); } }}