Package puremvc :: Package patterns :: Module observer :: Class Observer
[hide private]
[frames] | no frames]

type Observer

source code

              object --+
                       |
interfaces.IObserver --+
                       |
                      Observer

A base IObserver implementation.

An Observer is an object that encapsulates information about an interested object with a method that should be called when a particular INotification is broadcast.

In PureMVC, the Observer class assumes these responsibilities:

Encapsulate the notification (callback) method of the interested object.

Encapsulate the notification context (this) of the interested object.

Provide methods for setting the notification method and context.

Provide a method for notifying the interested object.


See Also:
View, Notification
Instance Methods [hide private]
 
__init__(self, notifyMethod, notifyContext)
Constructor.
source code
 
setNotifyMethod(self, notifyMethod)
Set the notification method.
source code
 
setNotifyContext(self, notifyContext)
Set the notification context.
source code
 
getNotifyMethod(self)
Get the notification method.
source code
 
getNotifyContext(self)
Get the notification context.
source code
 
notifyObserver(self, notification)
Notify the interested object.
source code
 
compareNotifyContext(self, obj)
Compare an object to the notification context.
source code
Class Variables [hide private]
  notify = None
  context = None
Method Details [hide private]

__init__(self, notifyMethod, notifyContext)
(Constructor)

source code 

Constructor.

The notification method on the interested object should take one parameter of type INotification

Parameters:
  • notifyMethod - the notification method of the interested object
  • notifyContext - the notification context of the interested object
Overrides: object.__init__

setNotifyMethod(self, notifyMethod)

source code 

Set the notification method.

The notification method should take one parameter of type INotification.

Parameters:
  • notifyMethod - the notification (callback) method of the interested object.
Overrides: interfaces.IObserver.setNotifyMethod

setNotifyContext(self, notifyContext)

source code 

Set the notification context.

Parameters:
  • notifyContext - the notification context (this) of the interested object.
Overrides: interfaces.IObserver.setNotifyContext

getNotifyMethod(self)

source code 

Get the notification method.

Returns:
the notification (callback) method of the interested object.

getNotifyContext(self)

source code 

Get the notification context.

Returns:
the notification context (this) of the interested object.

notifyObserver(self, notification)

source code 

Notify the interested object.

Parameters:
  • notification - the INotification to pass to the interested object's notification method.
Overrides: interfaces.IObserver.notifyObserver

compareNotifyContext(self, obj)

source code 

Compare an object to the notification context.

Parameters:
  • obj - the object to compare
Returns:
boolean indicating if the object and the notification context are the same
Overrides: interfaces.IObserver.compareNotifyContext