Trait Component

Source
pub trait Component:
    AnyComponent
    + Send
    + Sync
    + Any {
    type Props: Props + Clone;

Show 23 methods // Required methods fn component_id(&self) -> ComponentId; fn create(props: Self::Props, context: Context) -> Self where Self: Sized; fn update(&mut self, props: Self::Props) -> Result<(), ComponentError>; fn render(&self) -> Result<Vec<Node>, ComponentError>; fn as_any(&self) -> &dyn Any; fn as_any_mut(&mut self) -> &mut dyn Any; // Provided methods fn initialize(&mut self) -> Result<(), ComponentError> { ... } fn mount(&mut self) -> Result<(), ComponentError> { ... } fn on_mount( &mut self, _context: &MountContext, ) -> Result<(), ComponentError> { ... } fn before_mount(&mut self) -> Result<(), ComponentError> { ... } fn after_mount(&mut self) -> Result<(), ComponentError> { ... } fn state_changed(&mut self, _state_key: &str) -> Result<(), ComponentError> { ... } fn on_update( &mut self, _changes: &StateChanges, ) -> Result<(), ComponentError> { ... } fn request_update(&mut self) -> Result<(), ComponentError> { ... } fn should_update(&self, _new_props: &Self::Props) -> bool { ... } fn before_update( &mut self, _new_props: &Self::Props, ) -> Result<(), ComponentError> { ... } fn after_update(&mut self) -> Result<(), ComponentError> { ... } fn before_unmount(&mut self) -> Result<(), ComponentError> { ... } fn on_unmount( &mut self, _context: &UnmountContext, ) -> Result<(), ComponentError> { ... } fn after_unmount(&mut self) -> Result<(), ComponentError> { ... } fn unmount(&mut self) -> Result<(), ComponentError> { ... } fn cleanup(&mut self) -> Result<(), ComponentError> { ... } fn lifecycle_phase(&self) -> LifecyclePhase { ... }
}
Expand description

Enhanced component trait with improved lifecycle management

Required Associated Types§

Source

type Props: Props + Clone

The props type for this component

Required Methods§

Source

fn component_id(&self) -> ComponentId

Get unique component ID for debugging and tracking

Source

fn create(props: Self::Props, context: Context) -> Self
where Self: Sized,

Create a new component instance with enhanced tracking

Source

fn update(&mut self, props: Self::Props) -> Result<(), ComponentError>

Update component with new props

Source

fn render(&self) -> Result<Vec<Node>, ComponentError>

Render component - returns child nodes

Source

fn as_any(&self) -> &dyn Any

Convert to Any for downcasting

Source

fn as_any_mut(&mut self) -> &mut dyn Any

Convert to mutable Any for downcasting

Provided Methods§

Source

fn initialize(&mut self) -> Result<(), ComponentError>

Initialize the component - called immediately after creation Use this for setting up initial state and registering lifecycle hooks

Source

fn mount(&mut self) -> Result<(), ComponentError>

Mount component - called when component is first added to the tree Automatic state change detection and update scheduling is enabled after this point

Source

fn on_mount(&mut self, _context: &MountContext) -> Result<(), ComponentError>

Enhanced lifecycle hook - called when component is mounted with context

Source

fn before_mount(&mut self) -> Result<(), ComponentError>

Enhanced lifecycle hook - called before mount for initialization

Source

fn after_mount(&mut self) -> Result<(), ComponentError>

Enhanced lifecycle hook - called after mount for post-initialization

Source

fn state_changed(&mut self, _state_key: &str) -> Result<(), ComponentError>

Called when component state changes and updates are needed

Source

fn on_update(&mut self, _changes: &StateChanges) -> Result<(), ComponentError>

Enhanced lifecycle hook - called when state changes are detected

Source

fn request_update(&mut self) -> Result<(), ComponentError>

Request that this component be re-rendered

Source

fn should_update(&self, _new_props: &Self::Props) -> bool

Check if component should update given new props Override for performance optimization

Source

fn before_update( &mut self, _new_props: &Self::Props, ) -> Result<(), ComponentError>

Called before component updates with new props

Source

fn after_update(&mut self) -> Result<(), ComponentError>

Called after the component has updated

Source

fn before_unmount(&mut self) -> Result<(), ComponentError>

Called before component is unmounted Automatic cleanup of state subscriptions happens after this

Source

fn on_unmount( &mut self, _context: &UnmountContext, ) -> Result<(), ComponentError>

Enhanced lifecycle hook - called when component is unmounted with context

Source

fn after_unmount(&mut self) -> Result<(), ComponentError>

Enhanced lifecycle hook - called after unmount for final cleanup

Source

fn unmount(&mut self) -> Result<(), ComponentError>

Unmount component - called when component is removed from the tree

Source

fn cleanup(&mut self) -> Result<(), ComponentError>

Perform automatic cleanup (called by framework)

Source

fn lifecycle_phase(&self) -> LifecyclePhase

Get current lifecycle phase

Implementors§

Source§

impl Component for Button

Source§

impl Component for Card

Source§

impl Component for Input

Source§

impl Component for Layout

Source§

impl Component for ThemeProvider

Source§

impl Component for ComponentBase

Basic Component implementation for ComponentBase (primarily for testing)

Source§

impl Component for FlexibleCompoundComponent

Source§

impl Component for SlottedComponent

Source§

impl<H, T> Component for HOCWrapper<H, T>
where H: HigherOrderComponent<T> + Send + Sync + 'static, T: Component + Send + Sync + 'static, H::HOCProps: Send + Sync + 'static,

Source§

impl<T> Component for LazyComponent<T>
where T: Component + Send + Sync + 'static, T::Props: Send + Sync + 'static,

Source§

impl<T> Component for MemoComponent<T>
where T: Component + Memoizable + Send + Sync + 'static, T::Props: Send + Sync + 'static, T::MemoKey: Send + Sync + 'static,

Source§

impl<T, R> Component for RenderPropComponent<T, R>
where T: Clone + Send + Sync + 'static, R: RenderProp<T> + Clone + Send + Sync + 'static,