examples: better practice for view types in todos (#940)

This commit is contained in:
Greg Johnston 2023-04-23 17:33:45 -04:00 committed by GitHub
parent a08d6bae10
commit 79c12c0129
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

View file

@ -156,11 +156,11 @@ pub fn Todos(cx: Scope) -> impl IntoView {
todos.read(cx) todos.read(cx)
.map(move |todos| match todos { .map(move |todos| match todos {
Err(e) => { Err(e) => {
vec![view! { cx, <pre class="error">"Server Error: " {e.to_string()}</pre>}.into_any()] view! { cx, <pre class="error">"Server Error: " {e.to_string()}</pre>}.into_view(cx)
} }
Ok(todos) => { Ok(todos) => {
if todos.is_empty() { if todos.is_empty() {
vec![view! { cx, <p>"No tasks were found."</p> }.into_any()] view! { cx, <p>"No tasks were found."</p> }.into_view(cx)
} else { } else {
todos todos
.into_iter() .into_iter()
@ -175,9 +175,9 @@ pub fn Todos(cx: Scope) -> impl IntoView {
</ActionForm> </ActionForm>
</li> </li>
} }
.into_any()
}) })
.collect::<Vec<_>>() .collect::<Vec<_>>()
.into_view(cx)
} }
} }
}) })

View file

@ -209,11 +209,11 @@ pub fn Todos(cx: Scope) -> impl IntoView {
todos.read(cx) todos.read(cx)
.map(move |todos| match todos { .map(move |todos| match todos {
Err(e) => { Err(e) => {
vec![view! { cx, <pre class="error">"Server Error: " {e.to_string()}</pre>}.into_any()] view! { cx, <pre class="error">"Server Error: " {e.to_string()}</pre>}.into_view(cx)
} }
Ok(todos) => { Ok(todos) => {
if todos.is_empty() { if todos.is_empty() {
vec![view! { cx, <p>"No tasks were found."</p> }.into_any()] view! { cx, <p>"No tasks were found."</p> }.into_view(cx)
} else { } else {
todos todos
.into_iter() .into_iter()
@ -228,9 +228,9 @@ pub fn Todos(cx: Scope) -> impl IntoView {
</ActionForm> </ActionForm>
</li> </li>
} }
.into_any()
}) })
.collect::<Vec<_>>() .collect::<Vec<_>>()
.into_view(cx)
} }
} }
}) })

View file

@ -163,11 +163,11 @@ pub fn Todos(cx: Scope) -> impl IntoView {
todos.read(cx) todos.read(cx)
.map(move |todos| match todos { .map(move |todos| match todos {
Err(e) => { Err(e) => {
vec![view! { cx, <pre class="error">"Server Error: " {e.to_string()}</pre>}.into_any()] view! { cx, <pre class="error">"Server Error: " {e.to_string()}</pre>}.into_view(cx)
} }
Ok(todos) => { Ok(todos) => {
if todos.is_empty() { if todos.is_empty() {
vec![view! { cx, <p>"No tasks were found."</p> }.into_any()] view! { cx, <p>"No tasks were found."</p> }.into_view(cx)
} else { } else {
todos todos
.into_iter() .into_iter()
@ -182,9 +182,9 @@ pub fn Todos(cx: Scope) -> impl IntoView {
</ActionForm> </ActionForm>
</li> </li>
} }
.into_any()
}) })
.collect::<Vec<_>>() .collect::<Vec<_>>()
.into_view(cx)
} }
} }
}) })