View

View

new View()

A Multiton View implementation.

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

  • Maintain a cache of `Mediator` instances.
  • Provide methods for registering, retrieving, and removing `Mediators`.
  • Notifying `Mediators` when they are registered or removed.
  • Managing the observer lists for each `Notification` in the application.
  • Providing a method for attaching `Observers` to a `Notification`'s observer list.
  • Providing a method for broadcasting a `Notification`.
  • Notifying the `Observers` of a given `Notification` when it broadcast.
Source:
See:
  • Mediator Mediator
  • Observer Observer
  • Notification Notification

Members

(static) instanceMap :Map.<string, View>

Source:
Type:
  • Map.<string, View>

(static) MULTITON_MSG :string

Message Constants

Source:
Type:
  • string

(protected) mediatorMap :Map.<string, Mediator>

Source:
Type:

(protected) multitonKey :string

Source:
Type:
  • string

(protected) observerMap :Map.<string, Array.<Observer>>

Source:
Type:

Methods

(static) getInstance(key, factory) → {View}

View Multiton factory method.

Source:
Parameters:
Name Type Description
key string
factory function
Returns:
Type:
View

the Multiton instance of View

(static) removeView(key)

Remove a View instance

Source:
Parameters:
Name Type Description
key

multitonKey of View instance to remove

hasMediator(mediatorName) → {boolean}

Check if a Mediator is registered or not

Source:
Parameters:
Name Type Description
mediatorName string
Returns:
Type:
boolean

whether a Mediator is registered with the given mediatorName.

initializeView()

Initialize the Multiton View instance.

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

Source:

notifyObservers(notification)

Notify the `Observers` for a particular `Notification`.

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

Source:
Parameters:
Name Type Description
notification Notification

the Notification to notify Observers of.

registerMediator(mediator)

Register a Mediator instance with the View.

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

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

Source:
Parameters:
Name Type Description
mediator Mediator

a reference to the Mediator instance

registerObserver(notificationName, observer)

Register an `Observer` to be notified of `Notifications` with a given name.

Source:
Parameters:
Name Type Description
notificationName string

the name of the Notifications to notify this Observer of

observer Observer

the Observer to register

removeMediator(mediatorName) → {Mediator}

Remove a Mediator from the View.

Source:
Parameters:
Name Type Description
mediatorName string

name of the Mediator instance to be removed.

Returns:
Type:
Mediator

the Mediator that was removed from the View

removeObserver(notificationName, notifyContext)

Remove the observer for a given notifyContext from an observer list for a given Notification name.

Source:
Parameters:
Name Type Description
notificationName string

which observer list to remove from

notifyContext Object

remove the observer with this object as its notifyContext

retrieveMediator(mediatorName) → {Mediator}

Retrieve a Mediator from the View.

Source:
Parameters:
Name Type Description
mediatorName string

the name of the Mediator instance to retrieve.

Returns:
Type:
Mediator

the Mediator instance previously registered with the given mediatorName.

View

new View(key)

Constructor.

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

Source:
Parameters:
Name Type Description
key string
Throws:

Error if instance for this Multiton key has already been constructed

Type
Error

Members

(static) instanceMap :Map.<string, View>

Source:
Type:
  • Map.<string, View>

(static) MULTITON_MSG :string

Message Constants

Source:
Type:
  • string

(protected) mediatorMap :Map.<string, Mediator>

Source:
Type:

(protected) multitonKey :string

Source:
Type:
  • string

(protected) observerMap :Map.<string, Array.<Observer>>

Source:
Type:

Methods

(static) getInstance(key, factory) → {View}

View Multiton factory method.

Source:
Parameters:
Name Type Description
key string
factory function
Returns:
Type:
View

the Multiton instance of View

(static) removeView(key)

Remove a View instance

Source:
Parameters:
Name Type Description
key

multitonKey of View instance to remove

hasMediator(mediatorName) → {boolean}

Check if a Mediator is registered or not

Source:
Parameters:
Name Type Description
mediatorName string
Returns:
Type:
boolean

whether a Mediator is registered with the given mediatorName.

initializeView()

Initialize the Multiton View instance.

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

Source:

notifyObservers(notification)

Notify the `Observers` for a particular `Notification`.

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

Source:
Parameters:
Name Type Description
notification Notification

the Notification to notify Observers of.

registerMediator(mediator)

Register a Mediator instance with the View.

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

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

Source:
Parameters:
Name Type Description
mediator Mediator

a reference to the Mediator instance

registerObserver(notificationName, observer)

Register an `Observer` to be notified of `Notifications` with a given name.

Source:
Parameters:
Name Type Description
notificationName string

the name of the Notifications to notify this Observer of

observer Observer

the Observer to register

removeMediator(mediatorName) → {Mediator}

Remove a Mediator from the View.

Source:
Parameters:
Name Type Description
mediatorName string

name of the Mediator instance to be removed.

Returns:
Type:
Mediator

the Mediator that was removed from the View

removeObserver(notificationName, notifyContext)

Remove the observer for a given notifyContext from an observer list for a given Notification name.

Source:
Parameters:
Name Type Description
notificationName string

which observer list to remove from

notifyContext Object

remove the observer with this object as its notifyContext

retrieveMediator(mediatorName) → {Mediator}

Retrieve a Mediator from the View.

Source:
Parameters:
Name Type Description
mediatorName string

the name of the Mediator instance to retrieve.

Returns:
Type:
Mediator

the Mediator instance previously registered with the given mediatorName.