pub trait Lifecycle {
Show 17 methods
// Provided methods
fn retention_policy(&self) -> PageRetention { ... }
fn on_create(&self) { ... }
fn on_mount(&self, _node: NodeId) { ... }
fn on_update(&self, _node: NodeId) { ... }
fn on_activate(&self, _node: NodeId) { ... }
fn on_freeze(&self, _node: NodeId) { ... }
fn on_resume(&self, _node: NodeId) { ... }
fn on_unmount(&self, _node: NodeId) { ... }
fn on_destroy(&self) { ... }
fn on_error(&self, _error: &str) { ... }
fn on_appear(&self) { ... }
fn on_disappear(&self) { ... }
fn on_foreground(&self) { ... }
fn on_background(&self) { ... }
fn on_inactive(&self) { ... }
fn on_terminate(&self) { ... }
fn on_system_event(&self, _event: &SystemEvent) { ... }
}Expand description
Standalone lifecycle hook contract implemented by components and routed pages.
Business code overrides only the hooks it needs; every method provides a zero-cost no-op default.
Provided Methods§
Sourcefn retention_policy(&self) -> PageRetention
fn retention_policy(&self) -> PageRetention
Sourcefn on_create(&self)
fn on_create(&self)
Invoked once immediately before the component’s initial render pass executes.
§Arguments
&Self- Component or page instance reference.
Sourcefn on_mount(&self, _node: NodeId)
fn on_mount(&self, _node: NodeId)
Invoked once immediately after render attaches the root NodeId to the scene tree.
§Arguments
&Self- Component or page instance reference.NodeId- Mounted root scene node handle.
Sourcefn on_update(&self, _node: NodeId)
fn on_update(&self, _node: NodeId)
Invoked when external props, theme tokens, or cross-page state trigger a component update.
§Arguments
&Self- Component or page instance reference.NodeId- Active root scene node handle.
Sourcefn on_activate(&self, _node: NodeId)
fn on_activate(&self, _node: NodeId)
Invoked whenever this component or routed page becomes the active visible view.
§Arguments
&Self- Component or page instance reference.NodeId- Active root scene node handle.
Sourcefn on_freeze(&self, _node: NodeId)
fn on_freeze(&self, _node: NodeId)
Invoked when the router or parent suspends this subtree under PageRetention::Freeze.
§Arguments
&Self- Component or page instance reference.NodeId- Frozen root scene node handle.
Sourcefn on_resume(&self, _node: NodeId)
fn on_resume(&self, _node: NodeId)
Invoked when a previously frozen subtree resumes and coalesced cross-page updates flush.
§Arguments
&Self- Component or page instance reference.NodeId- Resumed root scene node handle.
Sourcefn on_unmount(&self, _node: NodeId)
fn on_unmount(&self, _node: NodeId)
Invoked immediately before the subtree is detached and its reactive scope is disposed.
§Arguments
&Self- Component or page instance reference.NodeId- Unmounting root scene node handle.
Sourcefn on_destroy(&self)
fn on_destroy(&self)
Invoked after the component’s reactive scope and child nodes have been fully destroyed.
§Arguments
&Self- Component or page instance reference.
Sourcefn on_error(&self, _error: &str)
fn on_error(&self, _error: &str)
Invoked when an error boundary or runtime fault surfaces inside this component subtree.
§Arguments
&Self- Component or page instance reference.&str- Diagnostic error message.
Sourcefn on_appear(&self)
fn on_appear(&self)
Invoked when this component, routed page, or application window becomes visually presented.
§Arguments
&Self- Component or page instance reference.
Sourcefn on_disappear(&self)
fn on_disappear(&self)
Invoked when this component, routed page, or application window ceases to be visually presented.
§Arguments
&Self- Component or page instance reference.
Sourcefn on_foreground(&self)
fn on_foreground(&self)
Invoked when the application returns to active foreground execution.
§Arguments
&Self- Component or page instance reference.
Sourcefn on_background(&self)
fn on_background(&self)
Invoked when the application enters suspended/hidden background execution.
§Arguments
&Self- Component or page instance reference.
Sourcefn on_inactive(&self)
fn on_inactive(&self)
Invoked when the application enters inactive status (occluded, app switcher, or deactivated).
§Arguments
&Self- Component or page instance reference.
Sourcefn on_terminate(&self)
fn on_terminate(&self)
Invoked when the application is terminating gracefully.
§Arguments
&Self- Component or page instance reference.
Sourcefn on_system_event(&self, _event: &SystemEvent)
fn on_system_event(&self, _event: &SystemEvent)
Invoked for every normalized cross-platform SystemEvent delivered while this component is active.
§Arguments
&Self- Component or page instance reference.&SystemEvent- Normalized cross-platform system event payload.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl Lifecycle for DynamicComponentSlot
Default Lifecycle hooks for DynamicComponentSlot.
impl Lifecycle for DynamicPageOutlet
Default Lifecycle hooks for DynamicPageOutlet.
impl Lifecycle for DynamicPageSlot
Default Lifecycle hooks for DynamicPageSlot.
impl Lifecycle for NodeId
No-op Lifecycle implementation allowing raw NodeId handles to participate seamlessly in Component APIs.