supense_integration.rs 946 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // const Posts: AtomFamily = |family| {
  2. // family.on_get(|key| {
  3. // //
  4. // })
  5. // };
  6. fn main() {
  7. wasm_bindgen_futures::spawn_local(dioxus_web::WebsysRenderer::start(App))
  8. }
  9. use std::future::Future;
  10. use dioxus_core::prelude::*;
  11. static App: FC<()> = |cx| {
  12. //
  13. let title = use_async_atom();
  14. let title_card = suspend(&cx, title, move |val| {
  15. //
  16. rsx!(in cx, div {
  17. h3 { "{val}" }
  18. })
  19. });
  20. // let fut = (use_async_atom(), use_async_atom());
  21. // let title_card2 = cx.suspend(fut, move |(text, text2)| {
  22. // cx.render(rsx!( h3 { "{text}" } ))
  23. // });
  24. cx.render(rsx! {
  25. div {
  26. {title_card}
  27. // {title_card2}
  28. }
  29. })
  30. };
  31. async fn use_async_atom() -> String {
  32. todo!()
  33. }
  34. fn suspend<'a, O>(
  35. c: &impl Scoped<'a>,
  36. f: impl Future<Output = O>,
  37. g: impl FnOnce(O) -> VNode<'a> + 'a,
  38. ) -> VNode<'a> {
  39. todo!()
  40. }