Dart DocumentationpuremvcMediator

Mediator Class

A base IMediator implementation.

In PureMVC, IMediator implementors assume these responsibilities:

  • Implement a common method which returns a list of all INotifications the IMediator has interest in.
  • Implement a notification (callback) method for handling INotifications.
  • Implement methods that are called when the IMediator is registered or removed from an IView.

Additionally, IMediators typically:

  • Act as an intermediary between one or more view components and the rest of the application.
  • Place Event listeners on view components, and implement handlers which often send INotifications or interact with IProxys to post or retrieve data.
  • Receive INotifications, (typically containing data) and updating view components in response.

When an IMediator is registered with the IView, the IMediator's listNotificationInterests method is called The IMediator will return a List of INotification names which it wishes to be notified about.

The IView will then create an IObserver object encapsulating that IMediator's and its handleNotification method and register the IObserver for each INotification name returned by the IMediator's listNotificationInterests method.

See INotification, IView

Extends

Notifier > Mediator

Implements

IMediator

Constructors

Code new Mediator(String name, [viewComponent]) #

Constructor

  • Param name - the name this IMediator will be registered with.
  • Param viewComponent - the View Component (optional)
Mediator( String this.name, [Dynamic this.viewComponent] ){ }

Methods

Code String getName() #

Get the IMediator instance's name.

String getName() 
{    
  return name;
}

Code getViewComponent() #

Get the IMediator's viewComponent.

  • Returns Dynamic - the View Component
Dynamic getViewComponent()
{    
  return viewComponent;
}

Code void handleNotification(INotification note) #

Handle an INotification.

void handleNotification( INotification note ) {}

Code List<String> listNotificationInterests() #

List INotification interests.

List<String> listNotificationInterests( )
{
  return new List<String>();
}

Code void onRegister() #

Called by the IView when the IMediator is registered.

void onRegister( ) {}

Code void onRemove() #

Called by the IView when the IMediator is removed.

void onRemove( ) {}

Code void setViewComponent(component) #

Set the IMediator's viewComponent.

void setViewComponent( Dynamic component ) 
{
  viewComponent = component;
}

Fields

Code String name #

This IMediator's name.

String name;

Code var viewComponent #

This IMediator's viewComponent.

Dynamic viewComponent;