🎨 Convierte el ciclo de renderizado en async

`prepare()` de `Component`, `render()` de `Region` y `Template`, y la
implementación de `ComponentRender` pasan a ser funciones async. Se
actualizan todos los componentes base, helpers, tests y ejemplos.
This commit is contained in:
Manuel Cillero 2026-07-06 00:48:41 +02:00
parent 9acd8cc51a
commit 9354894b3a
48 changed files with 436 additions and 365 deletions

View file

@ -8,6 +8,7 @@ struct TestMarkupComponent {
markup: Markup,
}
#[async_trait]
impl Component for TestMarkupComponent {
fn new() -> Self {
Self::default()
@ -17,7 +18,7 @@ impl Component for TestMarkupComponent {
cx.param_or::<bool>("renderable", true)
}
fn prepare(&self, _cx: &mut Context) -> Result<Markup, ComponentError> {
async fn prepare(&self, _cx: &mut Context) -> Result<Markup, ComponentError> {
Ok(self.markup.clone())
}
}
@ -74,7 +75,7 @@ async fn non_renderable_component_produces_empty_markup() {
let mut comp = TestMarkupComponent {
markup: html! { p { "Should never be rendered" } },
};
assert_eq!(comp.render(&mut cx).into_string(), "");
assert_eq!(comp.render(&mut cx).await.into_string(), "");
}
#[pagetop::test]
@ -93,7 +94,7 @@ async fn markup_from_component_equals_markup_reinjected_in_html_macro() {
let mut comp = TestMarkupComponent {
markup: markup.clone(),
};
comp.render(&mut cx).into_string()
comp.render(&mut cx).await.into_string()
};
// Vía 2: reinyectamos el Markup en `html!` directamente.