
Public Member Functions | |
| IList< string > | ListNotificationInterests () |
| void | HandleNotification (INotification notification) |
Handle an INotification. | |
| void | OnRegister () |
| Called by the View when the Mediator is registered. | |
| void | OnRemove () |
| Called by the View when the Mediator is removed. | |
Properties | |
| string | MediatorName [get] |
| object | ViewComponent [get, set] |
The IMediator's view component. | |
In PureMVC, IMediator implementors assume these responsibilities:
INotifications the IMediator has interest in.
Additionally, IMediators typically:
INotifications, interacting with of the rest of the PureMVC app
When an IMediator is registered with the IView, the IView will call the IMediator's listNotificationInterests method. The IMediator will return an IList of INotification names which it wishes to be notified about
The IView will then create an Observer object encapsulating that IMediator's (handleNotification) method and register it as an Observer for each INotification name returned by listNotificationInterests
A concrete IMediator implementor usually looks something like this:
using PureMVC.Patterns.~~; using PureMVC.Core.View.~~; using com.me.myapp.model.~~; using com.me.myapp.view.~~; using com.me.myapp.controller.~~; using System.Windows.Forms; using System.Data; public class MyMediator : Mediator, IMediator { public MyMediator( viewComponent:object ) { base( viewComponent ); combo.DataSourceChanged += new EventHandler(onChange); } public IList listNotificationInterests() { return new string[] { MyFacade.SET_SELECTION, MyFacade.SET_DATAPROVIDER }; } public void handleNotification( notification:INotification ) { switch ( notification.getName() ) { case MyFacade.SET_SELECTION: combo.SelectedItem = notification.getBody(); break; set the data source of the combo box case MyFacade.SET_DATASOURCE: combo.DataSource = notification.getBody(); break; } } Invoked when the combo box dispatches a change event, we send a notification with the protected void onChange(object sender, EventArgs e) { sendNotification( MyFacade.MYCOMBO_CHANGED, sender ); } A private getter for accessing the view object by class private ComboBox combo { get { return view as ComboBox; } } }
PureMVC.Interfaces.INotification
| void PureMVC.Interfaces.IMediator.HandleNotification | ( | INotification | notification | ) |
Handle an INotification.
| notification | The INotification to be handled |
Implemented in PureMVC.Patterns.Mediator.
| IList<string> PureMVC.Interfaces.IMediator.ListNotificationInterests | ( | ) |
List INotification interests
IList of the INotification names this IMediator has an interest inImplemented in PureMVC.Patterns.Mediator.
| void PureMVC.Interfaces.IMediator.OnRegister | ( | ) |
| void PureMVC.Interfaces.IMediator.OnRemove | ( | ) |
string PureMVC.Interfaces.IMediator.MediatorName [get] |
Tthe IMediator instance name
Implemented in PureMVC.Patterns.Mediator.
object PureMVC.Interfaces.IMediator.ViewComponent [get, set] |
1.5.8