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§
Required Methods§
Sourcefn component_id(&self) -> ComponentId
fn component_id(&self) -> ComponentId
Get unique component ID for debugging and tracking
Sourcefn create(props: Self::Props, context: Context) -> Selfwhere
Self: Sized,
fn create(props: Self::Props, context: Context) -> Selfwhere
Self: Sized,
Create a new component instance with enhanced tracking
Sourcefn update(&mut self, props: Self::Props) -> Result<(), ComponentError>
fn update(&mut self, props: Self::Props) -> Result<(), ComponentError>
Update component with new props
Sourcefn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Convert to mutable Any for downcasting
Provided Methods§
Sourcefn initialize(&mut self) -> Result<(), ComponentError>
fn initialize(&mut self) -> Result<(), ComponentError>
Initialize the component - called immediately after creation Use this for setting up initial state and registering lifecycle hooks
Sourcefn mount(&mut self) -> Result<(), ComponentError>
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
Sourcefn on_mount(&mut self, _context: &MountContext) -> Result<(), ComponentError>
fn on_mount(&mut self, _context: &MountContext) -> Result<(), ComponentError>
Enhanced lifecycle hook - called when component is mounted with context
Sourcefn before_mount(&mut self) -> Result<(), ComponentError>
fn before_mount(&mut self) -> Result<(), ComponentError>
Enhanced lifecycle hook - called before mount for initialization
Sourcefn after_mount(&mut self) -> Result<(), ComponentError>
fn after_mount(&mut self) -> Result<(), ComponentError>
Enhanced lifecycle hook - called after mount for post-initialization
Sourcefn state_changed(&mut self, _state_key: &str) -> Result<(), ComponentError>
fn state_changed(&mut self, _state_key: &str) -> Result<(), ComponentError>
Called when component state changes and updates are needed
Sourcefn on_update(&mut self, _changes: &StateChanges) -> Result<(), ComponentError>
fn on_update(&mut self, _changes: &StateChanges) -> Result<(), ComponentError>
Enhanced lifecycle hook - called when state changes are detected
Sourcefn request_update(&mut self) -> Result<(), ComponentError>
fn request_update(&mut self) -> Result<(), ComponentError>
Request that this component be re-rendered
Sourcefn should_update(&self, _new_props: &Self::Props) -> bool
fn should_update(&self, _new_props: &Self::Props) -> bool
Check if component should update given new props Override for performance optimization
Sourcefn before_update(
&mut self,
_new_props: &Self::Props,
) -> Result<(), ComponentError>
fn before_update( &mut self, _new_props: &Self::Props, ) -> Result<(), ComponentError>
Called before component updates with new props
Sourcefn after_update(&mut self) -> Result<(), ComponentError>
fn after_update(&mut self) -> Result<(), ComponentError>
Called after the component has updated
Sourcefn before_unmount(&mut self) -> Result<(), ComponentError>
fn before_unmount(&mut self) -> Result<(), ComponentError>
Called before component is unmounted Automatic cleanup of state subscriptions happens after this
Sourcefn on_unmount(
&mut self,
_context: &UnmountContext,
) -> Result<(), ComponentError>
fn on_unmount( &mut self, _context: &UnmountContext, ) -> Result<(), ComponentError>
Enhanced lifecycle hook - called when component is unmounted with context
Sourcefn after_unmount(&mut self) -> Result<(), ComponentError>
fn after_unmount(&mut self) -> Result<(), ComponentError>
Enhanced lifecycle hook - called after unmount for final cleanup
Sourcefn unmount(&mut self) -> Result<(), ComponentError>
fn unmount(&mut self) -> Result<(), ComponentError>
Unmount component - called when component is removed from the tree
Sourcefn cleanup(&mut self) -> Result<(), ComponentError>
fn cleanup(&mut self) -> Result<(), ComponentError>
Perform automatic cleanup (called by framework)
Sourcefn lifecycle_phase(&self) -> LifecyclePhase
fn lifecycle_phase(&self) -> LifecyclePhase
Get current lifecycle phase
Implementors§
Source§impl Component for ThemeProvider
impl Component for ThemeProvider
type Props = ThemeProviderProps
Source§impl Component for ComponentBase
Basic Component implementation for ComponentBase (primarily for testing)
impl Component for ComponentBase
Basic Component implementation for ComponentBase (primarily for testing)