IView The interface definition for a PureMVC View.

In PureMVC, the View class assumes these responsibilities:

  • Maintain a cache of IMediator instances.

  • Provide methods for registering, retrieving, and removing IMediators.

  • 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 is broadcast.

IView

interface IView {
    hasMediator(mediatorName: string): boolean;
    notifyObservers(notification: INotification): void;
    registerMediator(mediator: IMediator): void;
    registerObserver(notificationName: string, observer: IObserver): void;
    removeMediator(mediatorName: string): null | IMediator;
    removeObserver(notificationName: string, notifyContext: any): void;
    retrieveMediator(mediatorName: string): null | IMediator;
}

Implemented by

Methods

  • Check if a IMediator is registered or not

    Parameters

    • mediatorName: string

      The name of the IMediator to check.

    Returns boolean

    true if the IMediator is registered, otherwise false.

  • 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.

    Returns 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 IMediator to be registered.

    Returns void

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

    Parameters

    • notificationName: string

      The name of the notification to register the observer for.

    • observer: IObserver

      The observer to be registered.

    Returns void

  • Remove an IMediator from the View.

    Parameters

    • mediatorName: string

      name of the IMediator instance to be removed.

    Returns null | IMediator

    The removed IMediator, or null if not found.

  • Remove a group of observers from the observer list for a given Notification name.

    Parameters

    • notificationName: string

      which observer list to remove from

    • notifyContext: any

      removed the observers with this object as their notifyContext

    Returns void

  • Retrieve an IMediator from the View.

    Parameters

    • mediatorName: string

      the name of the IMediator instance to retrieve.

    Returns null | IMediator

    The IMediator associated with the given name, or null if not found.