Observer Event Design Pattern

In This Thought we are introduces an implementation when we can use the Observer pattern to keep all observer objects updated after things have changed.
The Observer Pattern describes the dependence relationship between one object (observable) to many objects (observers). It’s also called Model/View, Dependents, or Distributor/Listener pattern.

Encapsulate the core (or common or engine) components in a Subject abstraction, and the variable (or optional or user interface) components in an Observer hierarchy.

Structure :

 

It is mainly used to implement distributed event handling systems. Here the subject maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods.

<?php Mage::dispatchEvent('event_name', array('key'=>$value));?>

 

<config>
    <global>
        <events>
            <event_name>
                <observers>
                    <unique_name>
                        <class>Class_Name</class>
 <method>methodName</method>
                    </unique_name>
                </observers>
            </event_name>
        </events>
    </global>
</config>

 

For More About Design Patterns Click here

1 thought on “Observer Event Design Pattern

Leave a Reply

Your email address will not be published.