feat: abstract to rc wake
This commit is contained in:
1 parent
a38fc9e4ab
commit
e6c53803a6
12 files changed
+188
-67
No files matched your search
@@ -0,0 +1,38 @@
|
||||
use std::{cell::Cell, ptr::null_mut, time::Duration};
|
||||
|
||||
use dioxus_core::*;
|
||||
|
||||
#[tokio::test]
|
||||
async fn it_works() {
|
||||
let mut dom = VirtualDom::new(app);
|
||||
|
||||
let mut mutations = vec![];
|
||||
dom.rebuild(&mut mutations);
|
||||
|
||||
println!("mutations: {:?}", mutations);
|
||||
|
||||
dom.wait_for_work().await;
|
||||
}
|
||||
|
||||
fn app(cx: Scope) -> Element {
|
||||
let dy = cx.component(async_child, (), "async_child");
|
||||
VNode::single_component(&cx, dy, "app")
|
||||
}
|
||||
|
||||
async fn async_child(cx: Scope<'_>) -> Element {
|
||||
println!("rendering async child");
|
||||
|
||||
let fut = cx.use_hook(|| {
|
||||
Box::pin(async {
|
||||
println!("Starting sleep");
|
||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||
println!("Sleep ended");
|
||||
})
|
||||
});
|
||||
|
||||
fut.await;
|
||||
|
||||
println!("Future awaited");
|
||||
|
||||
None
|
||||
}
|
||||
@@ -17,14 +17,14 @@ async fn it_works() {
|
||||
fn app(cx: Scope) -> Element {
|
||||
cx.spawn(async {
|
||||
for x in 0..10 {
|
||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||
tokio::time::sleep(Duration::from_millis(500)).await;
|
||||
println!("Hello, world! {x}");
|
||||
}
|
||||
});
|
||||
|
||||
cx.spawn(async {
|
||||
for x in 0..10 {
|
||||
tokio::time::sleep(Duration::from_millis(500)).await;
|
||||
tokio::time::sleep(Duration::from_millis(250)).await;
|
||||
println!("Hello, world does! {x}");
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user