Spry User Guide - Support - Adobe
Spry User Guide - Support - Adobe
Spry User Guide - Support - Adobe
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Objects as region observers<br />
To receive notifications, an object must define a method for each notification it is interested in receiving, and then<br />
register itself as an observer on the region.<br />
The following example shows an object being registered as an observer on a dynamic region:<br />
<br />
...<br />
// Create an observer object and define the methods to receive the notifications<br />
// it wants.<br />
myObserver = new Object;<br />
myObserver.onPostUpdate = function(notifier, data)<br />
{<br />
alert("onPostUpdate called for " + data.regionID);<br />
};<br />
...<br />
// Call addObserver() to register the object as an observer.<br />
<strong>Spry</strong>.Data.Region.addObserver("employeeListRegion", myObserver);<br />
...<br />
// You can unregister your object so it stops recieving notifications<br />
// with a call to removeObserver().<br />
<strong>Spry</strong>.Data.Region.removeObserver("employeeListRegion", myObserver);<br />
...<br />
<br />
...<br />
<br />
...<br />
<br />
The first argument for each notification method is the object that is sending the notification. For region observers,<br />
this is not the region object. The second argument is an object that contains a regionID property that identifies the<br />
region that triggered the notification.<br />
To stop an object from receiving notifications, the object must be removed from the list of observers with a call to<br />
removeObserver().<br />
Functions as region observers<br />
Functions can also be registered as observers. The main difference between object and function observers is that an<br />
object is only notified for the notification methods it defines, whereas a function observer is called for every type of<br />
event notification.<br />
The following example shows a function being registered as an observer on a dynamic region:<br />
SPRY<br />
<strong>User</strong> <strong>Guide</strong><br />
134