IController The interface definition for a PureMVC Controller.

In PureMVC, an IController implementor follows the 'Command and Controller' strategy, and assumes these responsibilities:

  • Remembering which ICommands are intended to handle which INotifications.

  • Registering itself as an IObserver with the View for each INotification that it has an ICommand mapping for.

  • Creating a new instance of the proper ICommand to handle a given INotification when notified by the View.

  • Calling the ICommand's execute method, passing in the INotification.

IController

interface IController {
    executeCommand(notification: INotification): void;
    hasCommand(notificationName: string): boolean;
    registerCommand(notificationName: string, factory: (() => ICommand)): void;
    removeCommand(notificationName: string): void;
}

Implemented by

Methods

  • Execute the ICommand previously registered as the handler for INotifications with the given notification name.

    Parameters

    • notification: INotification

      the INotification to execute the associated ICommand for

    Returns void

  • Check if a Command 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.

  • Register a particular ICommand class as the handler for a particular INotification.

    Parameters

    • notificationName: string

      the name of the INotification

    • factory: (() => ICommand)

      A factory that returns ICommand

    Returns void

  • Remove a previously registered ICommand to INotification mapping.

    Parameters

    • notificationName: string

      the name of the INotification to remove the ICommand mapping for

    Returns void