Skip to main content

Component

Trait Component 

Source
pub trait Component: 'static {
    // Required method
    fn view(&self) -> RenderNode;

    // Provided methods
    fn on_event(&mut self, _event: &Event) -> EventResult { ... }
    fn debug_name(&self) -> &'static str { ... }
}
Expand description

Imperative-state components re-render only when on_event returns EventResult::Handled; reactive-state components re-render automatically on signal change.

Required Methods§

Source

fn view(&self) -> RenderNode

Provided Methods§

Source

fn on_event(&mut self, _event: &Event) -> EventResult

Source

fn debug_name(&self) -> &'static str

Human-readable widget type name for the devtools tree inspector.

Trait Implementations§

Source§

impl Component for Box<dyn Component>

Source§

fn view(&self) -> RenderNode

Source§

fn on_event(&mut self, event: &Event) -> EventResult

Source§

fn debug_name(&self) -> &'static str

Human-readable widget type name for the devtools tree inspector.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Component for Box<dyn Component>

Source§

fn view(&self) -> RenderNode

Source§

fn on_event(&mut self, event: &Event) -> EventResult

Source§

fn debug_name(&self) -> &'static str

Source§

impl Component for Box<dyn LayoutItem>

Source§

fn view(&self) -> RenderNode

Source§

fn on_event(&mut self, event: &Event) -> EventResult

Source§

fn debug_name(&self) -> &'static str

Implementors§