From 81fb98aa8615da0f63873666dbcf9236c7506a8f Mon Sep 17 00:00:00 2001 From: John Lewis Date: Mon, 25 Nov 2024 14:33:03 +0100 Subject: [PATCH] feat(site): impl prime domain debugging resouce on homepage --- crates/site-app/src/pages/mod.rs | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/crates/site-app/src/pages/mod.rs b/crates/site-app/src/pages/mod.rs index 5bfdf6e..bcd3597 100644 --- a/crates/site-app/src/pages/mod.rs +++ b/crates/site-app/src/pages/mod.rs @@ -1,9 +1,28 @@ -use leptos::prelude::*; +use leptos::{either::Either, prelude::*}; use crate::components::Section; #[component] pub fn HomePage() -> impl IntoView { + let fallback = move || { + view! { +

"Loading photos..."

+ } + }; + let photos = Resource::new(|| (), |_| enumerate_photos()); + let photos_suspense_viewer = move || { + Suspend::new(async move { + match photos.await { + Ok(photos) => Either::Left(view! { +
{ format!("{photos:#?}") }
+ }), + Err(e) => Either::Right(view! { +
{ format!("{e}") }
+ }), + } + }) + }; + view! {

@@ -12,6 +31,16 @@ pub fn HomePage() -> impl IntoView {

"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne merninisti licere mihi ista probare, quae sunt a te dicta? Duo Reges: constructio interrete. Quae cum dixisset, finem ille."

+ + { photos_suspense_viewer } +
} } + +#[server] +pub async fn enumerate_photos() -> Result, ServerFnError> { + let service: prime_domain::DynPrimeDomainService = expect_context(); + + service.enumerate_photos().await.map_err(ServerFnError::new) +}