Trait ruex::prelude::Controller
source · pub trait Controller<Body>where
Body: Debug + 'static,{
// Required methods
fn register_command(
&self,
interest: Interest,
command: Rc<dyn Command<Body>>
);
fn execute_command(&self, notification: Rc<dyn Notification<Body>>);
fn remove_command(&self, interest: &Interest);
fn has_command(&self, interest: &Interest) -> bool;
}
Expand description
The definition for a PureMVC Controller.
In PureMVC, an Controller implementor follows the ‘Command and Controller’ strategy, and assumes these responsibilities:
- Remembering which Command’s are intended to handle which Notification’s
- Registering itself as an Observer with the View for each Notification that it has an Command mapping for
- Creating a new instance of the proper Command to handle a given Notification when notified by the View
- Calling the Command’s execute method, passing in the Notification
Required Methods§
sourcefn register_command(&self, interest: Interest, command: Rc<dyn Command<Body>>)
fn register_command(&self, interest: Interest, command: Rc<dyn Command<Body>>)
Register a particular Command class as the handler for a particular Notification.
sourcefn execute_command(&self, notification: Rc<dyn Notification<Body>>)
fn execute_command(&self, notification: Rc<dyn Notification<Body>>)
Execute the Command previously registered as the handler for Notification’s with the given notification name.
sourcefn remove_command(&self, interest: &Interest)
fn remove_command(&self, interest: &Interest)
Remove a previously registered Command to Notification mapping.
sourcefn has_command(&self, interest: &Interest) -> bool
fn has_command(&self, interest: &Interest) -> bool
Check if a Command is registered for a given Notification