Observer pattern
From Ajax Patterns
The Observer Pattern concept involves at least two classes, the 'observed' class and one or more other classes -- 'observers' -- which have methods that are called by (inside) the 'observed' class. Observed classes often have a method to register observer classes and their methods to be called, and perhaps condition arguments. For example, an 'observed' class that handles errors may call methods in an 'observer' class that sends an email or text message to an administrator. A class that updates a database might be 'observed' and trigger methods in an 'observer' class which updates cached page output, and can also trigger methods in another 'observer' class that analyzes the database for patterns -- which can trigger the actions of other classes (like BUY or SELL recommendations) etc. An AJAX (or Comet) output class could observe (register its methods with) a class that checks for changes in a database. Or, to put it the other way around, 'observer' classes register with an 'observed' class, and the observers methods are called when conditions in the 'observed' class trigger them. At this point in time, this is the closest php comes to 'server side events'. (October, 2006)
Time your website with
WebWait - from the creator of AjaxPatterns.org
