pub trait Component {
type Message;
// Required methods
fn on_event(
&mut self,
event: &Event,
) -> impl Future<Output = Option<Vec<Self::Message>>>;
fn render(&mut self, ctx: &ViewContext) -> Frame;
}Expand description
A component that can process events and emit typed messages.
Required Associated Types§
Required Methods§
Sourcefn on_event(
&mut self,
event: &Event,
) -> impl Future<Output = Option<Vec<Self::Message>>>
fn on_event( &mut self, event: &Event, ) -> impl Future<Output = Option<Vec<Self::Message>>>
Process an event and return the outcome.
None— event not recognized, propagate to parentSome(vec![])— event consumed, no messagesSome(vec![msg, ...])— event consumed, emit messages
Sourcefn render(&mut self, ctx: &ViewContext) -> Frame
fn render(&mut self, ctx: &ViewContext) -> Frame
Render the current state to a frame.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.