mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-07 23:46:52 +02:00
README Observer
This commit is contained in:
14
Observer/README.md
Normal file
14
Observer/README.md
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# 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.
|
@@ -3,17 +3,7 @@
|
|||||||
namespace DesignPatterns\Observer;
|
namespace DesignPatterns\Observer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Observer pattern
|
* class UserObserver
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
* PHP already defines two interfaces that can help to implement this pattern: SplObserver and SplSubject
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class UserObserver implements \SplObserver
|
class UserObserver implements \SplObserver
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user