mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 06:44:17 +00:00
suspense_tests: actually wait for other resource in nested case
This commit is contained in:
parent
a50c6b0140
commit
202abd1d35
2 changed files with 19 additions and 27 deletions
|
@ -1,4 +1,4 @@
|
|||
use leptos::{logging, prelude::*};
|
||||
use leptos::prelude::*;
|
||||
use leptos_router::{
|
||||
components::{Outlet, ParentRoute, Redirect, Route, Router, Routes, A},
|
||||
SsrMode, StaticSegment,
|
||||
|
@ -155,31 +155,24 @@ fn NestedResourceInside() -> impl IntoView {
|
|||
view! {
|
||||
<div>
|
||||
<Suspense fallback=|| "Loading 1...">
|
||||
{move || {
|
||||
one_second.get().map(|_| {
|
||||
let two_second = Resource::new_serde(|| (), move |_| async move {
|
||||
logging::log!("creating two_second resource");
|
||||
second_wait_fn(WAIT_TWO_SECONDS).await
|
||||
});
|
||||
view! {
|
||||
{move || one_second.get().map(|_|
|
||||
view! {
|
||||
<p id="loaded-1">"One Second: Loaded 1!"</p>
|
||||
}
|
||||
)}
|
||||
<Suspense fallback=|| "Loading 2...">
|
||||
{move || {
|
||||
two_second.get().map(|x| view! {
|
||||
<span id="loaded-2">"Loaded 2 (created inside first suspense)!: " {format!("{x:?}")}</span>
|
||||
<button on:click=move |_| set_count.update(|n| *n += 1)>
|
||||
{count}
|
||||
</button>
|
||||
})
|
||||
}}
|
||||
</Suspense>
|
||||
}
|
||||
})
|
||||
}}
|
||||
{Suspend(async move {
|
||||
_ = one_second.await;
|
||||
let two_second = Resource::new_serde(|| (), move |_| async move {
|
||||
second_wait_fn(WAIT_TWO_SECONDS).await
|
||||
});
|
||||
view! {
|
||||
<p id="loaded-1">"One Second: Loaded 1!"</p>
|
||||
<Suspense fallback=|| "Loading 2...">
|
||||
<span id="loaded-2">
|
||||
"Loaded 2 (created inside first suspense)!: "
|
||||
{Suspend(async move { format!("{:?}", two_second.await)})}
|
||||
</span>
|
||||
<button on:click=move |_| set_count.update(|n| *n += 1)>
|
||||
{count}
|
||||
</button>
|
||||
</Suspense>
|
||||
}
|
||||
})}
|
||||
</Suspense>
|
||||
</div>
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ async fn main() -> std::io::Result<()> {
|
|||
HttpServer::new(move || {
|
||||
// Generate the list of routes in your Leptos App
|
||||
let routes = generate_route_list(App);
|
||||
println!("{routes:#?}");
|
||||
let leptos_options = &conf.leptos_options;
|
||||
let site_root = &leptos_options.site_root;
|
||||
|
||||
|
|
Loading…
Reference in a new issue