PureMVC AS3 Framework - [Standard Version] | All Packages | All Classes | Index | Frames No Frames |
Class Observer

Package | org.puremvc.as3.patterns.observer
Class | public class Observer
Implements | IObserver

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

Public Methods

| Method | Defined by
--- | --- | ---
|  | Observer(notifyMethod:Function, notifyContext:Object) Constructor. | Observer
|  | compareNotifyContext(object:Object):Boolean Compare an object to the notification context. | Observer
|  | notifyObserver(notification:INotification):void Notify the interested object. | Observer
|  | setNotifyContext(notifyContext:Object):void Set the notification context. | Observer
|  | setNotifyMethod(notifyMethod:Function):void Set the notification method. | Observer

Constructor detail

Observer | () | constructor

`public function Observer(notifyMethod:Function, notifyContext:Object)`

Constructor.

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

Parameters

| `notifyMethod:Function` — the notification method of the interested object
| `notifyContext:Object` — the notification context of the interested object

Method detail

compareNotifyContext | () | method

`public function compareNotifyContext(object:Object):Boolean`

Compare an object to the notification context.

Parameters

| `object:Object` — the object to compare

Returns

| `Boolean` — boolean indicating if the object and the notification context are the same

notifyObserver | () | method |

`public function notifyObserver(notification:INotification):void`

Notify the interested object.

Parameters

| `notification:INotification` — the `INotification` to pass to the interested object's notification method.

setNotifyContext | () | method |

`public function setNotifyContext(notifyContext:Object):void`

Set the notification context.

Parameters

| `notifyContext:Object` — the notification context (this) of the interested object.

setNotifyMethod | () | method |

`public function setNotifyMethod(notifyMethod:Function):void`

Set the notification method.

The notification method should take one parameter of type `INotification`.

Parameters

| `notifyMethod:Function` — the notification (callback) method of the interested object.