Trait tuirealm::Component

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

The component describes the application level component, which is a wrapper around the MockComponent, which, in addition to all the methods exposed by the mock, it will handle the event 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. (Don’t forget to derive PartialEq for your 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 MockComponent and many of them are available in the standard library at https://github.com/veeso/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.

Implementors§