task.rs 661 B

123456789101112131415161718192021222324252627282930313233
  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 mut mutations = vec![];
  7. dom.rebuild(&mut mutations);
  8. println!("mutations: {:?}", mutations);
  9. dom.wait_for_work().await;
  10. }
  11. fn app(cx: Scope) -> Element {
  12. cx.spawn(async {
  13. for x in 0..10 {
  14. tokio::time::sleep(Duration::from_secs(1)).await;
  15. println!("Hello, world! {x}");
  16. }
  17. });
  18. cx.spawn(async {
  19. for x in 0..10 {
  20. tokio::time::sleep(Duration::from_millis(500)).await;
  21. println!("Hello, world does! {x}");
  22. }
  23. });
  24. None
  25. }