2015-04-03 10:57:00 +02:00
..
2014-07-31 14:47:55 -05:00
2015-04-03 10:57:00 +02:00
2014-07-31 14:13:53 -05:00
2014-06-20 15:36:24 +08:00

Observer

Purpose

To implement a publish/subscribe behaviour to an object, whenever a "Subject" object changes it's state, the attached "Observers" will be notified. It is used to shorten the amount of coupled objects and uses loose coupling instead.

Examples

  • a message queue system is observed to show the progress of a job in a GUI

Note

PHP already defines two interfaces that can help to implement this pattern: SplObserver and SplSubject.

UML Diagram

Alt Observer UML Diagram