IFacade The interface definition for a PureMVC Facade.

The Facade Pattern suggests providing a single class to act as a central point of communication for a subsystem.

In PureMVC, the Facade acts as an interface between the core MVC actors (Model, View, Controller) and the rest of your application.

IFacade

interface IFacade {
    hasCommand(notificationName: string): boolean;
    hasMediator(mediatorName: string): boolean;
    hasProxy(proxyName: string): boolean;
    notifyObservers(notification: INotification): void;
    registerCommand(notificationName: string, factory: (() => ICommand)): void;
    registerMediator(mediator: IMediator): void;
    registerProxy(proxy: IProxy): void;
    removeCommand(notificationName: string): void;
    removeMediator(mediatorName: string): null | IMediator;
    removeProxy(proxyName: string): null | IProxy;
    retrieveMediator(mediatorName: string): null | IMediator;
    retrieveProxy(proxyName: string): null | IProxy;
    sendNotification(notificationName: string, body?: any, type?: string): void;
}

Hierarchy (view full)

Implemented by

Methods

  • Check if a ICommand is registered for a given Notification

    Parameters

    • notificationName: string

      The name of the notification to check.

    Returns boolean

    true if a command is registered for the notification name, false otherwise.

  • Check if a Mediator is registered or not

    Parameters

    • mediatorName: string

      The name of the mediator to check.

    Returns boolean

    true if a mediator is registered with the name, false otherwise.

  • Check if a Proxy is registered

    Parameters

    • proxyName: string

      The name of the proxy to check.

    Returns boolean

    true if a proxy is registered with the name, false otherwise.

  • Notify Observers.

    This method is left public mostly for backward compatibility, and to allow you to send custom notification classes using the facade.

    Usually you should just call sendNotification and pass the parameters, never having to construct the notification yourself.

    Parameters

    • notification: INotification

      the INotification to have the View notify Observers of.

    Returns void

  • Register an ICommand with the Controller

    Parameters

    • notificationName: string

      the name of the INotification to associate the ICommand with.

    • factory: (() => ICommand)

      A factory that creates an instance of the ICommand to be registered.

    Returns void

  • Register an IMediator instance with the View.

    Parameters

    • mediator: IMediator

      a reference to the IMediator instance

    Returns void

  • Register an IProxy with the Model by name.

    Parameters

    • proxy: IProxy

      the IProxy to be registered with the Model.

    Returns void

  • Remove a previously registered ICommand to INotification mapping from the Controller.

    Parameters

    • notificationName: string

      the name of the INotification to remove the ICommand mapping for

    Returns void

  • Remove a IMediator instance from the View.

    Parameters

    • mediatorName: string

      The name of the mediator to remove.

    Returns null | IMediator

    The removed mediator instance if found, or null if no mediator was registered with the given name.

  • Remove an IProxy instance from the Model by name.

    Parameters

    • proxyName: string

      the IProxy to remove from the Model.

    Returns null | IProxy

    The removed proxy instance if found, or null if no proxy was registered with the given name.

  • Retrieve an IMediator instance from the View.

    Parameters

    • mediatorName: string

      the name of the IMediator instance to retrieve

    Returns null | IMediator

    The mediator instance if found, or null if no mediator is registered with the given name.

  • Retrieve a IProxy from the Model by name.

    Parameters

    • proxyName: string

      the name of the IProxy instance to be retrieved.

    Returns null | IProxy

    the IProxy previously registered by proxyName with the Model.

  • Send a INotification.

    Convenience method to prevent having to construct new notification instances in our implementation code.

    Parameters

    • notificationName: string

      The name of the notification to send.

    • Optionalbody: any

      Optional data associated with the notification.

    • Optionaltype: string

      Optional type of the notification.

    Returns void