Skip to main content

Component

Trait Component 

Source
pub trait Component: Send + Sync {
    // Required method
    fn render(&self, state: &GA3) -> Element;

    // Provided methods
    fn initial_state(&self) -> GA3 { ... }
    fn type_name(&self) -> &'static str { ... }
}
Expand description

A component is a geometric morphism from state to renderable output.

Components transform geometric state into Element trees. The state is always a GA3 multivector, but components can interpret it in any way they choose (scalar counter, 3D position, etc.).

Required Methods§

Source

fn render(&self, state: &GA3) -> Element

Render the component given the current geometric state.

The state represents the component’s local state. Components should be pure functions of their state.

Provided Methods§

Source

fn initial_state(&self) -> GA3

Get the initial state for this component.

Returns the geometric state to use when the component mounts.

Source

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

Get the component’s type name for debugging.

Implementors§

Source§

impl<A, B> Component for ComposedComponent<A, B>
where A: Component, B: Component,

Source§

impl<F> Component for FnComponent<F>
where F: Fn(&GA3) -> Element + Send + Sync,