Trait ruex::prelude::Mediator

source ·
pub trait Mediator<Body>: NotifyContext + Debug + Sized + Anywhere
    Body: Debug + 'static,{
    // Required methods
    fn view_component(&self) -> Option<Rc<dyn View<Body>>>;
    fn set_view_component(&mut self, component: Option<Rc<dyn View<Body>>>);
    fn list_notification_interests(&self) -> &[Interest];
    fn handle_notification(&self, notification: Rc<dyn Notification<Body>>);
    fn on_register(&self);
    fn on_remove(&self);
}
Expand description

The definition for a PureMVC Mediator.

In PureMVC, Mediator implementors assume these responsibilities:

  • Implement a common method which returns a list of all Notification’s the Mediator has interest in.
  • Implement a common notification (callback) method.

Additionally, Mediator’s typically:

  • Act as an intermediary between one or more view components such as text boxes or list controls, maintaining references and coordinating their behavior.
  • In Flash-based apps, this is often the place where event listeners are added to view components, and their handlers implemented.
  • Respond to and generate Notification’s, interacting with of the rest of the PureMVC app.

When an Mediator is registered with the View, the View will call the Mediator’s list_notification_interests method. The Mediator will return an Vec of Notification names which it wishes to be notified about.

The View will then create an Observer object encapsulating that Mediator’s handle_notification method and register it as an Observer for each Notification name returned by list_notification_interests.

Required Methods§

source

fn view_component(&self) -> Option<Rc<dyn View<Body>>>

Get the Mediator’s view component.

source

fn set_view_component(&mut self, component: Option<Rc<dyn View<Body>>>)

Set the Mediator’s view component.

source

fn list_notification_interests(&self) -> &[Interest]

List Notification interests.

source

fn handle_notification(&self, notification: Rc<dyn Notification<Body>>)

Handle an Notification.

source

fn on_register(&self)

Called by the View when the Mediator is registered

source

fn on_remove(&self)

Called by the View when the Mediator is removed

Implementors§

source§

impl<Body> Mediator<Body> for BaseMediator<Body>where Body: Debug + 'static,