wip: polish some more things

This commit is contained in:
Jonathan Kelley committed 2021-12-29 21:28:28 -05:00
1 parent 2d58d380be
commit 14961023f9
32 files changed
+265 -370

No files matched your search

-1
View File
@@ -50,7 +50,6 @@ anyhow = "1.0.42"
dioxus-html = { path = "../html" }
fern = { version = "0.6.0", features = ["colored"] }
rand = { version = "0.8.4", features = ["small_rng"] }
simple_logger = "1.13.0"
dioxus-core-macro = { path = "../core-macro", version = "^0.1.2" }
criterion = "0.3.5"
thiserror = "1.0.30"
+1 -1
View File
@@ -6,7 +6,7 @@ To build new apps with Dioxus or to extend the ecosystem with new hooks or compo
```rust
fn app(cx: Scope<()>) -> Element {
fn app(cx: Scope) -> Element {
rsx!(cx, div { "hello world" })
}
+1 -1
View File
@@ -11,7 +11,7 @@ fn main() {
dbg!(edits);
}
fn parent(cx: Scope<()>) -> Element {
fn parent(cx: Scope) -> Element {
let value = cx.use_hook(|_| String::new(), |f| f);
cx.render(rsx! {
+1 -1
View File
@@ -9,7 +9,7 @@ fn main() {
let _ = VirtualDom::new(parent);
}
fn parent(cx: Scope<()>) -> Element {
fn parent(cx: Scope) -> Element {
let value = cx.use_hook(|_| String::new(), |f| f);
cx.render(rsx! {
+11 -1
View File
@@ -84,7 +84,7 @@ pub enum VNode<'src> {
/// # Example
///
/// ```rust, ignore
/// fn Example(cx: Scope<()>) -> Element {
/// fn Example(cx: Scope) -> Element {
/// ...
/// }
///
@@ -740,6 +740,12 @@ impl IntoVNode<'_> for &'static str {
}
}
impl IntoVNode<'_> for String {
fn into_vnode(self, cx: NodeFactory) -> VNode {
cx.text(format_args!("{}", self))
}
}
impl IntoVNode<'_> for Arguments<'_> {
fn into_vnode(self, cx: NodeFactory) -> VNode {
cx.text(self)
@@ -758,3 +764,7 @@ impl<'a> IntoVNode<'a> for &VNode<'a> {
self.decouple()
}
}
trait IntoAcceptedVnode<'a> {
fn into_accepted_vnode(self, cx: NodeFactory<'a>) -> VNode<'a>;
}
+1 -1
View File
@@ -490,7 +490,7 @@ impl ScopeState {
/// # Example
///
/// ```rust, ignore
/// fn App(cx: Scope<()>) -> Element {
/// fn App(cx: Scope) -> Element {
/// rsx!(cx, div { "Subtree {id}"})
/// };
/// ```
+9 -9
View File
@@ -80,7 +80,7 @@ use std::{any::Any, collections::VecDeque, iter::FromIterator, pin::Pin, sync::A
/// Putting everything together, you can build an event loop around Dioxus by using the methods outlined above.
///
/// ```rust, ignore
/// fn App(cx: Scope<()>) -> Element {
/// fn App(cx: Scope) -> Element {
/// cx.render(rsx!{
/// div { "Hello World" }
/// })
@@ -127,7 +127,7 @@ impl VirtualDom {
///
/// # Example
/// ```rust, ignore
/// fn Example(cx: Scope<()>) -> Element {
/// fn Example(cx: Scope) -> Element {
/// cx.render(rsx!( div { "hello world" } ))
/// }
///
@@ -388,7 +388,7 @@ impl VirtualDom {
/// # Example
///
/// ```rust, ignore
/// fn App(cx: Scope<()>) -> Element {
/// fn App(cx: Scope) -> Element {
/// cx.render(rsx!( div {"hello"} ))
/// }
///
@@ -544,7 +544,7 @@ impl VirtualDom {
/// Useful when needing to render nodes from outside the VirtualDom, such as in a test.
///
/// ```rust
/// fn Base(cx: Scope<()>) -> Element {
/// fn Base(cx: Scope) -> Element {
/// rsx!(cx, div {})
/// }
///
@@ -564,7 +564,7 @@ impl VirtualDom {
/// Useful when needing to render nodes from outside the VirtualDom, such as in a test.
///
/// ```rust
/// fn Base(cx: Scope<()>) -> Element {
/// fn Base(cx: Scope) -> Element {
/// rsx!(cx, div {})
/// }
///
@@ -586,7 +586,7 @@ impl VirtualDom {
///
///
/// ```rust
/// fn Base(cx: Scope<()>) -> Element {
/// fn Base(cx: Scope) -> Element {
/// rsx!(cx, div {})
/// }
///
@@ -609,7 +609,7 @@ impl VirtualDom {
///
///
/// ```rust
/// fn Base(cx: Scope<()>) -> Element {
/// fn Base(cx: Scope) -> Element {
/// rsx!(cx, div {})
/// }
///
@@ -753,7 +753,7 @@ pub enum SchedulerMsg {
///
/// # Example
/// ```rust
/// fn App(cx: Scope<()>) -> Element {
/// fn App(cx: Scope) -> Element {
/// rsx!(cx, div {
/// onclick: move |_| println!("Clicked!")
/// })
@@ -871,7 +871,7 @@ impl<'a, const A: bool> FragmentBuilder<'a, A> {
/// ## Example
///
/// ```rust, ignore
/// fn App(cx: Scope<()>) -> Element {
/// fn App(cx: Scope) -> Element {
/// cx.render(rsx!{
/// CustomCard {
/// h1 {}2
+1 -1
View File
@@ -10,7 +10,7 @@ fn test_borrowed_state() {
let _ = VirtualDom::new(Parent);
}
fn Parent(cx: Scope<()>) -> Element {
fn Parent(cx: Scope) -> Element {
let value = cx.use_hook(|_| String::new(), |f| &*f);
cx.render(rsx! {
+7 -7
View File
@@ -28,7 +28,7 @@ fn new_dom<P: 'static + Send>(app: Component<P>, props: P) -> VirtualDom {
/// In debug, this should also toss a warning.
#[test]
fn test_memory_leak() {
fn app(cx: Scope<()>) -> Element {
fn app(cx: Scope) -> Element {
let val = cx.use_hook(|_| 0, |f| f);
*val += 1;
@@ -68,7 +68,7 @@ fn test_memory_leak() {
})
}
fn child(cx: Scope<()>) -> Element {
fn child(cx: Scope) -> Element {
rsx!(cx, div { "goodbye world" })
}
@@ -85,7 +85,7 @@ fn test_memory_leak() {
#[test]
fn memo_works_properly() {
fn app(cx: Scope<()>) -> Element {
fn app(cx: Scope) -> Element {
let val = cx.use_hook(|_| 0, |f| f);
*val += 1;
@@ -164,7 +164,7 @@ fn free_works_on_root_props() {
#[test]
fn free_works_on_borrowed() {
fn app(cx: Scope<()>) -> Element {
fn app(cx: Scope) -> Element {
cx.render(rsx! {
child(a: "alpha", b: "asd".to_string())
})
@@ -203,7 +203,7 @@ fn free_works_on_root_hooks() {
}
}
fn app(cx: Scope<()>) -> Element {
fn app(cx: Scope) -> Element {
let name = cx.use_hook(|_| Droppable(String::from("asd")), |f| f);
rsx!(cx, div { "{name.0}" })
}
@@ -214,7 +214,7 @@ fn free_works_on_root_hooks() {
#[test]
fn old_props_arent_stale() {
fn app(cx: Scope<()>) -> Element {
fn app(cx: Scope) -> Element {
dbg!("rendering parent");
let cnt = cx.use_hook(|_| 0, |f| f);
*cnt += 1;
@@ -261,7 +261,7 @@ fn old_props_arent_stale() {
#[test]
fn basic() {
fn app(cx: Scope<()>) -> Element {
fn app(cx: Scope) -> Element {
rsx!(cx, div {
child(a: "abcdef".to_string())
})