mirror of
https://github.com/leptos-rs/leptos
synced 2024-09-20 06:21:57 +00:00
examples: better practice for view types in todos (#940)
This commit is contained in:
parent
a08d6bae10
commit
79c12c0129
3 changed files with 9 additions and 9 deletions
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue