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

Package | org.puremvc.as3.core
Class | public class View
Implements | IView

A Singleton `IView` implementation.

In PureMVC, the `View` class assumes these responsibilities:

- Maintain a cache of `IMediator` instances.
- Provide methods for registering, retrieving, and removing `IMediators`.
- Notifiying `IMediators` when they are registered or removed.
- Managing the observer lists for each `INotification` in the application.
- Providing a method for attaching `IObservers` to an `INotification`'s observer list.
- Providing a method for broadcasting an `INotification`.
- Notifying the `IObservers` of a given `INotification` when it broadcast.

See also

Mediator
Observer
Notification

Protected Properties

| Property | Defined by
--- | --- | ---
|  | instance : IView [static] | View
|  | mediatorMap : Array | View
|  | observerMap : Array | View

Public Methods

| Method | Defined by
--- | --- | ---
|  | View() Constructor. | View
|  | getInstance():IView [static] View Singleton Factory method. | View
|  | hasMediator(mediatorName:String):Boolean Check if a Mediator is registered or not | View
|  | notifyObservers(notification:INotification):void Notify the `IObservers` for a particular `INotification`. | View
|  | registerMediator(mediator:IMediator):void Register an `IMediator` instance with the `View`. | View
|  | registerObserver(notificationName:String, observer:IObserver):void Register an `IObserver` to be notified of `INotifications` with a given name. | View
|  | removeMediator(mediatorName:String):IMediator Remove an `IMediator` from the `View`. | View
|  | retrieveMediator(mediatorName:String):IMediator Retrieve an `IMediator` from the `View`. | View

Protected Methods

| Method | Defined by
--- | --- | ---
|  | initializeView():void Initialize the Singleton View instance. | View

Protected Constants

| Constant | Defined by
--- | --- | ---
|  | SINGLETON_MSG : String = "View Singleton already constructed!" | View

Property detail

instance | property

`protected static var instance:IView`

mediatorMap | property |

`protected var mediatorMap:Array`

observerMap | property |

`protected var observerMap:Array`
Constructor detail

View | () | constructor

`public function View()`

Constructor.

This `IView` implementation is a Singleton, so you should not call the constructor directly, but instead call the static Singleton Factory method `View.getInstance()`

Throws

| `` — Error if Singleton instance has already been constructed

Method detail

getInstance | () | method

`public static function getInstance():IView`

View Singleton Factory method.

Returns

| `IView` — the Singleton instance of `View`

hasMediator | () | method |

`public function hasMediator(mediatorName:String):Boolean`

Check if a Mediator is registered or not

Parameters

| `mediatorName:String`

Returns

| `Boolean` — whether a Mediator is registered with the given `mediatorName`.

initializeView | () | method |

`protected function initializeView():void`

Initialize the Singleton View instance.

Called automatically by the constructor, this is your opportunity to initialize the Singleton instance in your subclass without overriding the constructor.

notifyObservers | () | method |

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

Notify the `IObservers` for a particular `INotification`.

All previously attached `IObservers` for this `INotification`'s list are notified and are passed a reference to the `INotification` in the order in which they were registered.

Parameters

| `notification:INotification` — the `INotification` to notify `IObservers` of.

registerMediator | () | method |

`public function registerMediator(mediator:IMediator):void`

Register an `IMediator` instance with the `View`.

Registers the `IMediator` so that it can be retrieved by name, and further interrogates the `IMediator` for its `INotification` interests.

If the `IMediator` returns any `INotification` names to be notified about, an `Observer` is created encapsulating the `IMediator` instance's `handleNotification` method and registering it as an `Observer` for all `INotifications` the `IMediator` is interested in.

Parameters

| `mediator:IMediator` — the name to associate with this `IMediator` instance

registerObserver | () | method |

`public function registerObserver(notificationName:String, observer:IObserver):void`

Register an `IObserver` to be notified of `INotifications` with a given name.

Parameters

| `notificationName:String` — the name of the `INotifications` to notify this `IObserver` of
| `observer:IObserver` — the `IObserver` to register

removeMediator | () | method |

`public function removeMediator(mediatorName:String):IMediator`

Remove an `IMediator` from the `View`.

Parameters

| `mediatorName:String` — name of the `IMediator` instance to be removed.

Returns

| `IMediator` — the `IMediator` that was removed from the `View`

retrieveMediator | () | method |

`public function retrieveMediator(mediatorName:String):IMediator`

Retrieve an `IMediator` from the `View`.

Parameters

| `mediatorName:String` — the name of the `IMediator` instance to retrieve.

Returns

| `IMediator` — the `IMediator` instance previously registered with the given `mediatorName`.

Constant detail

SINGLETON_MSG | constant

`protected const SINGLETON_MSG:String = "View Singleton already constructed!"`