Struct ruex::foundation::patterns::default::BaseController
source · pub struct BaseController<Body>where
Body: Debug + 'static,{ /* private fields */ }
Expand description
A Singleton Controller implementation.
In PureMVC, the Controller class 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.
Your application must register Command’s with the Controller. The simplest way is to subclass Facade, and use its register_command method to add your registrations.
Implementations§
source§impl<Body> BaseController<Body>where
Body: Debug + 'static,
impl<Body> BaseController<Body>where Body: Debug + 'static,
sourcepub fn new() -> Self
pub fn new() -> Self
Create instance of BaseController.
Actually, you have to reimplement the Controller for your purposes with Singleton pattern.
This View implementation is keept here in educational purposes only.
sourcepub fn as_context(&self) -> Rc<dyn NotifyContext>
pub fn as_context(&self) -> Rc<dyn NotifyContext>
Reprecent controller as NotifyContext
Trait Implementations§
source§impl<Body> Controller<Body> for BaseController<Body>where
Body: Debug + 'static,
impl<Body> Controller<Body> for BaseController<Body>where Body: Debug + 'static,
source§fn 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.
source§fn has_command(&self, interest: &Interest) -> bool
fn has_command(&self, interest: &Interest) -> bool
Check if a Command is registered for a given Notification
source§fn 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.
source§fn remove_command(&self, interest: &Interest)
fn remove_command(&self, interest: &Interest)
Remove a previously registered Command to Notification mapping.
source§impl<Body> Debug for BaseController<Body>where
Body: Debug + 'static,
impl<Body> Debug for BaseController<Body>where Body: Debug + 'static,
source§impl<Body> Singleton for BaseController<Body>where
Body: Debug + 'static,
impl<Body> Singleton for BaseController<Body>where Body: Debug + 'static,
source§fn global() -> &'static Self
fn global() -> &'static Self
Controller Singleton Factory method
It is not possible to implement Singleton with generics. So you should implement it in your final code only.
Error: use of generic parameter from outer function