task.rs 635 B

1234567891011121314151617181920212223242526272829303132
  1. use std::time::Duration;
  2. use dioxus_core::*;
  3. #[tokio::test]
  4. async fn it_works() {
  5. let mut dom = VirtualDom::new(app);
  6. let mutations = dom.rebuild();
  7. println!("mutations: {:?}", mutations);
  8. dom.wait_for_work().await;
  9. }
  10. fn app(cx: Scope) -> Element {
  11. cx.spawn(async {
  12. for x in 0..10 {
  13. tokio::time::sleep(Duration::from_millis(500)).await;
  14. println!("Hello, world! {x}");
  15. }
  16. });
  17. cx.spawn(async {
  18. for x in 0..10 {
  19. tokio::time::sleep(Duration::from_millis(250)).await;
  20. println!("Hello, world does! {x}");
  21. }
  22. });
  23. None
  24. }