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
(protected) observerMap :Map.<string, Array.<Observer>>
- Source:
Type:
-
Map.<string, Array.<Observer>>
Methods
(static) getInstance(key, factory) → {View}
View Multiton factory method.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string
|
|
factory |
function
|
(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 |
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 |
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 |
observer |
Observer
|
the |
removeMediator(mediatorName) → {Mediator}
Remove a Mediator from the View.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
mediatorName |
string
|
name of the |
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 |