euv_core/component/trait.rs
1use crate::*;
2
3/// Trait defining the lifecycle of a component.
4///
5/// Components are the primary building blocks of euv applications.
6/// Each component has its own state, message type, and rendering logic.
7pub trait Component {
8 /// The type of messages this component can receive.
9 type Message;
10 /// The type of properties passed to this component.
11 type Properties;
12
13 /// Creates a new component instance with the given properties and context.
14 fn create(properties: Self::Properties, context: ComponentContext) -> Self;
15
16 /// Updates the component state in response to a message.
17 fn update(&mut self, message: Self::Message) -> bool;
18
19 /// Renders the component to a virtual DOM node.
20 fn view(&self) -> VirtualNode;
21}