mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 06:44:17 +00:00
examples: update to Suspend::new()
This commit is contained in:
parent
efb699a319
commit
4107203da2
14 changed files with 20 additions and 20 deletions
|
@ -85,7 +85,7 @@ pub fn fetch_example() -> impl IntoView {
|
|||
<Transition fallback=|| view! { <div>"Loading..."</div> } {..spreadable}>
|
||||
<ErrorBoundary fallback>
|
||||
<ul>
|
||||
{move || Suspend(async move {
|
||||
{move || Suspend::new(async move {
|
||||
cats.await
|
||||
.map(|cats| {
|
||||
cats.iter()
|
||||
|
|
|
@ -20,7 +20,7 @@ pub fn Story() -> impl IntoView {
|
|||
},
|
||||
);
|
||||
|
||||
Suspense(SuspenseProps::builder().fallback(|| "Loading...").children(ToChildren::to_children(move || Suspend(async move {
|
||||
Suspense(SuspenseProps::builder().fallback(|| "Loading...").children(ToChildren::to_children(move || Suspend::new(async move {
|
||||
match story.await.clone() {
|
||||
None => Either::Left("Story not found."),
|
||||
Some(story) => {
|
||||
|
|
|
@ -19,7 +19,7 @@ pub fn User() -> impl IntoView {
|
|||
view! {
|
||||
<div class="user-view">
|
||||
<Suspense fallback=|| view! { "Loading..." }>
|
||||
{move || Suspend(async move { match user.await.clone() {
|
||||
{move || Suspend::new(async move { match user.await.clone() {
|
||||
None => Either::Left(view! { <h1>"User not found."</h1> }),
|
||||
Some(user) => Either::Right(view! {
|
||||
<div>
|
||||
|
|
|
@ -20,7 +20,7 @@ pub fn Story() -> impl IntoView {
|
|||
},
|
||||
);
|
||||
|
||||
Suspense(SuspenseProps::builder().fallback(|| "Loading...").children(ToChildren::to_children(move || Suspend(async move {
|
||||
Suspense(SuspenseProps::builder().fallback(|| "Loading...").children(ToChildren::to_children(move || Suspend::new(async move {
|
||||
match story.await.clone() {
|
||||
None => Either::Left("Story not found."),
|
||||
Some(story) => {
|
||||
|
|
|
@ -19,7 +19,7 @@ pub fn User() -> impl IntoView {
|
|||
view! {
|
||||
<div class="user-view">
|
||||
<Suspense fallback=|| view! { "Loading..." }>
|
||||
{move || Suspend(async move { match user.await.clone() {
|
||||
{move || Suspend::new(async move { match user.await.clone() {
|
||||
None => Either::Left(view! { <h1>"User not found."</h1> }),
|
||||
Some(user) => Either::Right(view! {
|
||||
<div>
|
||||
|
|
|
@ -26,7 +26,7 @@ pub fn Story() -> impl IntoView {
|
|||
},
|
||||
);
|
||||
|
||||
Suspense(SuspenseProps::builder().fallback(|| "Loading...").children(ToChildren::to_children(move || Suspend(async move {
|
||||
Suspense(SuspenseProps::builder().fallback(|| "Loading...").children(ToChildren::to_children(move || Suspend::new(async move {
|
||||
match story.await.ok().flatten() {
|
||||
None => Either::Left("Story not found."),
|
||||
Some(story) => {
|
||||
|
|
|
@ -26,7 +26,7 @@ pub fn User() -> impl IntoView {
|
|||
view! {
|
||||
<div class="user-view">
|
||||
<Suspense fallback=|| view! { "Loading..." }>
|
||||
{move || Suspend(async move { match user.await.ok().flatten() {
|
||||
{move || Suspend::new(async move { match user.await.ok().flatten() {
|
||||
None => Either::Left(view! { <h1>"User not found."</h1> }),
|
||||
Some(user) => Either::Right(view! {
|
||||
<div>
|
||||
|
|
|
@ -96,7 +96,7 @@ pub fn ContactList() -> impl IntoView {
|
|||
get_contacts(search.get())
|
||||
});
|
||||
let contacts = move || {
|
||||
Suspend(async move {
|
||||
Suspend::new(async move {
|
||||
// this data doesn't change frequently so we can use .map().collect() instead of a keyed <For/>
|
||||
contacts.await
|
||||
.into_iter()
|
||||
|
@ -155,7 +155,7 @@ pub fn Contact() -> impl IntoView {
|
|||
});
|
||||
|
||||
let contact_display = move || {
|
||||
Suspend(async move {
|
||||
Suspend::new(async move {
|
||||
match contact.await {
|
||||
None => Either::Left(
|
||||
view! { <p>"No contact with this ID was found."</p> },
|
||||
|
|
|
@ -64,7 +64,7 @@ fn HomePage() -> impl IntoView {
|
|||
view! {
|
||||
<h1>"My Great Blog"</h1>
|
||||
<Suspense fallback=move || view! { <p>"Loading posts..."</p> }>
|
||||
<p>"number of posts: " {Suspend(async move { posts2.await })}</p>
|
||||
<p>"number of posts: " {Suspend::new(async move { posts2.await })}</p>
|
||||
</Suspense>
|
||||
<Suspense fallback=move || view! { <p>"Loading posts..."</p> }>
|
||||
<ul>
|
||||
|
@ -105,7 +105,7 @@ fn Post() -> impl IntoView {
|
|||
}
|
||||
});
|
||||
|
||||
let post_view = Suspend(async move {
|
||||
let post_view = Suspend::new(async move {
|
||||
match post_resource.await.to_owned() {
|
||||
Ok(Ok(post)) => Ok(view! {
|
||||
<h1>{post.title.clone()}</h1>
|
||||
|
|
|
@ -131,7 +131,7 @@ fn HomePage() -> impl IntoView {
|
|||
view! {
|
||||
<h1>"My Great Blog"</h1>
|
||||
<Suspense fallback=move || view! { <p>"Loading posts..."</p> }>
|
||||
<p>"number of posts: " {Suspend(async move { posts2.await })}</p>
|
||||
<p>"number of posts: " {Suspend::new(async move { posts2.await })}</p>
|
||||
</Suspense>
|
||||
<Suspense fallback=move || view! { <p>"Loading posts..."</p> }>
|
||||
<ul>
|
||||
|
@ -182,7 +182,7 @@ fn Post() -> impl IntoView {
|
|||
}
|
||||
});
|
||||
|
||||
let post_view = Suspend(async move {
|
||||
let post_view = Suspend::new(async move {
|
||||
match post_resource.await {
|
||||
Ok(Ok(post)) => {
|
||||
Ok(view! {
|
||||
|
@ -199,7 +199,7 @@ fn Post() -> impl IntoView {
|
|||
_ => Err(PostError::ServerError),
|
||||
}
|
||||
});
|
||||
let comments_view = Suspend(async move {
|
||||
let comments_view = Suspend::new(async move {
|
||||
match comments_resource.await {
|
||||
Ok(comments) => Ok(view! {
|
||||
<h1>"Comments"</h1>
|
||||
|
|
|
@ -181,7 +181,7 @@ fn NestedResourceInside() -> impl IntoView {
|
|||
<Suspense fallback=|| {
|
||||
"Loading 1..."
|
||||
}>
|
||||
{Suspend(async move {
|
||||
{Suspend::new(async move {
|
||||
_ = one_second.await;
|
||||
let two_second = Resource::new(
|
||||
|| (),
|
||||
|
@ -192,7 +192,7 @@ fn NestedResourceInside() -> impl IntoView {
|
|||
<Suspense fallback=|| "Loading 2...">
|
||||
<span id="loaded-2">
|
||||
"Loaded 2 (created inside first suspense)!: "
|
||||
{Suspend(async move { format!("{:?}", two_second.await) })}
|
||||
{Suspend::new(async move { format!("{:?}", two_second.await) })}
|
||||
</span>
|
||||
<button on:click=move |_| set_count.update(|n| *n += 1)>{count}</button>
|
||||
</Suspense>
|
||||
|
@ -322,7 +322,7 @@ fn LocalResource() -> impl IntoView {
|
|||
one_second.get().map(|_| view! { <p id="loaded-1">"One Second: Loaded 1!"</p> })
|
||||
}}
|
||||
{move || {
|
||||
Suspend(async move {
|
||||
Suspend::new(async move {
|
||||
let value = local.await;
|
||||
view! { <p id="loaded-2">"One Second: Local Loaded " {value} "!"</p> }
|
||||
})
|
||||
|
|
|
@ -113,7 +113,7 @@ pub fn Todos() -> impl IntoView {
|
|||
);
|
||||
|
||||
let existing_todos = move || {
|
||||
Suspend(async move {
|
||||
Suspend::new(async move {
|
||||
todos
|
||||
.await
|
||||
.map(|todos| {
|
||||
|
|
|
@ -134,7 +134,7 @@ pub fn Todos() -> impl IntoView {
|
|||
);
|
||||
|
||||
let existing_todos = move || {
|
||||
Suspend(async move {
|
||||
Suspend::new(async move {
|
||||
todos
|
||||
.await
|
||||
.map(|todos| {
|
||||
|
|
|
@ -134,7 +134,7 @@ pub fn Todos() -> impl IntoView {
|
|||
);
|
||||
|
||||
let existing_todos = move || {
|
||||
Suspend(async move {
|
||||
Suspend::new(async move {
|
||||
todos
|
||||
.await
|
||||
.map(|todos| {
|
||||
|
|
Loading…
Reference in a new issue