Skip to main content

AppComponent

Trait AppComponent 

Source
pub trait AppComponent<Msg, UserEvent>: Component + Any
where Msg: PartialEq, UserEvent: Eq + PartialEq + Clone,
{ // Required method fn on(&mut self, ev: &Event<UserEvent>) -> Option<Msg>; }
Expand description

The app component describes the application level component, which is a wrapper around the Component, which, in addition to all the methods exposed by the base component, it will handle the Events coming from the View.

The Event are passed to the on method, which will eventually return a Msg, which is defined in your application as an enum. In your application you should have a Component for each element on your UI, but the logic to implement is very tiny, since the most of the work should already be done into the Component and many of them are available in the standard library at tui-realm-stdlib.

Don’t forget you can find an example in the examples/ directory and you can discover many more information about components in the repository documentation.

Required Methods§

Source

fn on(&mut self, ev: &Event<UserEvent>) -> Option<Msg>

Handle input event and update internal states. Returns a Msg to the view. If None is returned it means there’s no message to return for the provided event.

Implementations§

Source§

impl<Msg, UserEvent> dyn AppComponent<Msg, UserEvent>
where Msg: PartialEq, UserEvent: Eq + PartialEq + Clone,

Source

pub fn as_any(&self) -> &dyn Any

Convenience function to cast to Any.

Source

pub fn as_any_mut(&mut self) -> &mut dyn Any

Convenience function to cast to Any mutably.

Implementors§