work_sync.rs 746 B

123456789101112131415161718192021222324252627282930
  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::{arena::SharedResources, diff::DiffMachine, prelude::*, scope::Scope};
  6. use dioxus_core as dioxus;
  7. use dioxus_html as dioxus_elements;
  8. use futures_util::FutureExt;
  9. #[test]
  10. fn worksync() {
  11. static App: FC<()> = |cx| {
  12. cx.render(rsx! {
  13. div {"hello"}
  14. })
  15. };
  16. let mut dom = VirtualDom::new(App);
  17. let mut fut = dom.rebuild_async().boxed_local();
  18. let mutations = loop {
  19. let g = (&mut fut).now_or_never();
  20. if g.is_some() {
  21. break g.unwrap().unwrap();
  22. }
  23. };
  24. dbg!(mutations);
  25. }