chore: tweak generic arguments and iterators in rsx

This commit is contained in:
Jonathan Kelley committed 2022-11-15 20:58:56 -08:00
1 parent e8ae830cf2
commit e09b6bf813
7 files changed
+93 -66

No files matched your search

+1 -1
View File
@@ -16,7 +16,7 @@ fn app(cx: Scope) -> Element {
oninput: move |e| script.set(e.value.clone()),
}
button {
onclick: move |_| eval(script),
onclick: move |_| eval(script.to_string()),
"Execute"
}
}
+1 -1
View File
@@ -72,7 +72,7 @@ fn app(cx: Scope) -> Element {
td { class:"col-md-1" }
td { class:"col-md-1", "{item.key}" }
td { class:"col-md-1", onclick: move |_| selected.set(Some(id)),
a { class: "lbl", item.labels }
a { class: "lbl", "{item.labels[0]}{item.labels[1]}{item.labels[2]}" }
}
td { class: "col-md-1",
a { class: "remove", onclick: move |_| { items.write().remove(id); },
+19
View File
@@ -0,0 +1,19 @@
use std::fmt::Display;
use dioxus::prelude::*;
fn main() {
dioxus_desktop::launch(app);
}
fn app(cx: Scope) -> Element {
cx.render(rsx! {
generic_child::<i32>{}
})
}
fn generic_child<T>(cx: Scope) -> Element {
cx.render(rsx! {
div {}
})
}
+1 -1
View File
@@ -183,7 +183,7 @@ fn app(cx: Scope) -> Element {
// Components can be generic too
// This component takes i32 type to give you typed input
TypedInput::<TypedInputProps<i32>> {}
TypedInput::<i32> {}
// Type inference can be used too
TypedInput { initial: 10.0 }
+3 -2
View File
@@ -8,11 +8,12 @@ fn app(cx: Scope) -> Element {
cx.render(rsx!(
// Use Map directly to lazily pull elements
(0..10).map(|f| rsx! { "{f}" }),
// Collect into an intermediate collection if necessary
// Collect into an intermediate collection if necessary, and call into_iter
["a", "b", "c"]
.into_iter()
.map(|f| rsx! { "{f}" })
.collect::<Vec<_>>(),
.collect::<Vec<_>>()
.into_iter(),
// Use optionals
Some(rsx! { "Some" }),
))