♻️ Refactoriza la API de Children e InRegion
- Patrón prototipo en `InRegion`: cada petición recibe clones profundos. - `ComponentClone` habilita clonar `dyn Component` de forma segura. - `ChildTyped<C>` renombrado a `Slot<C>`, elimina `ChildTypedOp`. - `Mutex` en lugar de `Arc<RwLock>` en `Child` y `Slot`. - `is_renderable` y `setup_before_prepare` reciben `&Context`. - Nuevos tests para `Children`, `ChildOp` y `Slot`.
This commit is contained in:
parent
04e3d5b3c2
commit
54f990b11c
33 changed files with 740 additions and 314 deletions
|
|
@ -6,12 +6,13 @@ mod error;
|
|||
pub use error::ComponentError;
|
||||
|
||||
mod definition;
|
||||
pub use definition::{Component, ComponentRender};
|
||||
pub use definition::{Component, ComponentClone, ComponentRender};
|
||||
|
||||
mod children;
|
||||
pub use children::Slot;
|
||||
pub use children::Children;
|
||||
pub use children::ComponentGuard;
|
||||
pub use children::{Child, ChildOp};
|
||||
pub use children::{Typed, TypedOp};
|
||||
|
||||
mod message;
|
||||
pub use message::{MessageLevel, StatusMessage};
|
||||
|
|
@ -29,7 +30,7 @@ pub use context::{AssetsOp, Context, ContextError, Contextual};
|
|||
///
|
||||
/// ```rust
|
||||
/// # use pagetop::prelude::*;
|
||||
/// #[derive(AutoDefault)]
|
||||
/// #[derive(AutoDefault, Clone)]
|
||||
/// struct SampleComponent {
|
||||
/// renderable: Option<FnIsRenderable>,
|
||||
/// }
|
||||
|
|
@ -39,12 +40,12 @@ pub use context::{AssetsOp, Context, ContextError, Contextual};
|
|||
/// Self::default()
|
||||
/// }
|
||||
///
|
||||
/// fn is_renderable(&self, cx: &mut Context) -> bool {
|
||||
/// fn is_renderable(&self, cx: &Context) -> bool {
|
||||
/// // Si hay callback, se usa; en caso contrario, se renderiza por defecto.
|
||||
/// self.renderable.map_or(true, |f| f(cx))
|
||||
/// }
|
||||
///
|
||||
/// fn prepare_component(&self, _cx: &mut Context) -> Result<Markup, ComponentError> {
|
||||
/// fn prepare(&self, _cx: &mut Context) -> Result<Markup, ComponentError> {
|
||||
/// Ok(html! { "Visible component" })
|
||||
/// }
|
||||
/// }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue