Documented
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
//! # Component Module
|
||||
//!
|
||||
//! Provides the component system that forms the foundation of OSUI.
|
||||
//! Components are reusable units of UI that can manage their own state
|
||||
//! and respond to events.
|
||||
|
||||
pub mod context;
|
||||
pub mod scope;
|
||||
|
||||
@@ -10,10 +16,15 @@ use crate::View;
|
||||
|
||||
use context::Context;
|
||||
|
||||
/// A Component is an implementor of the ComponentImpl trait, wrapped in Arc
|
||||
pub type Component = Arc<dyn ComponentImpl>;
|
||||
|
||||
/// An event handler function stored in a mutex for thread-safe mutation
|
||||
pub type EventHandler = Arc<Mutex<dyn FnMut(&Arc<Context>, &dyn Any) + Send + Sync>>;
|
||||
|
||||
/// Trait implemented by components to render themselves
|
||||
pub trait ComponentImpl: Send + Sync {
|
||||
/// Renders the component within the given context, returning a View
|
||||
fn call(&self, cx: &Arc<Context>) -> View;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user