Gumbo_Interface_Observer



Observer Pattern Interface, Observer

An Observer is simply an object that wants to receive constant updates to the changes of another object (Observerable). The Observer constructor should register with the Observerable. The Observer should also define a destructor method (__destruct) to remove itself from any Observerable objects it registered with.

Author(s): Michael Luster <mluster79@yahoo.com>
License:New BSD License
Copyright:Copyright (c) 2007, iBayou, Michael Luster
Link:http://sourceforge.net/projects/phpgumbo
Version:0.0.1

Interface Methods

public void update ( array $data ) [line 64]

Receives updated information from an Observerable object

The Observerable will send changes to the Observer through this method. The data is a key=>val array, containing important information about the Observerable. Each Observer will be required to parse the array for the correct details. For example, if an Observerable send out updates on it's current status ($data['status'] = value), the Observer should look for just the 'status' key.

 foreach ($data as $key=>$val) {
 	if ($key == "status") {
 		// do something with the value
 	}
 }

The key=>value approach was used because a single Observer can be registered with multiple Observerable objects.

Parameter(s):

  • (array) $data :: key=>val array with important data for the Observer

[ Top ]