work_sync.rs 796 B

1234567891011121314151617181920212223242526272829303132333435
  1. //! Diffing is interruptible, but uses yield_now which is loop-pollable
  2. //!
  3. //! This means you can actually call it synchronously if you want.
  4. use anyhow::{Context, Result};
  5. use dioxus::{
  6. arena::SharedResources,
  7. diff::{CreateMeta, DiffInstruction, DiffMachine},
  8. prelude::*,
  9. scope::Scope,
  10. };
  11. use dioxus_core as dioxus;
  12. use dioxus_html as dioxus_elements;
  13. use futures_util::FutureExt;
  14. #[test]
  15. fn worksync() {
  16. static App: FC<()> = |cx| {
  17. cx.render(rsx! {
  18. div {"hello"}
  19. })
  20. };
  21. let mut dom = VirtualDom::new(App);
  22. let mut fut = dom.rebuild_async().boxed_local();
  23. let mutations = loop {
  24. let g = (&mut fut).now_or_never();
  25. if g.is_some() {
  26. break g.unwrap().unwrap();
  27. }
  28. };
  29. dbg!(mutations);
  30. }