async.rs 658 B

123456789101112131415161718192021222324252627282930313233343536
  1. use std::pin::Pin;
  2. use dioxus_core::prelude::*;
  3. use std::future::Future;
  4. fn main() {}
  5. const App: FC<()> = |cx| {
  6. // create a new future
  7. let mut fut = cx.use_hook(
  8. || {
  9. //
  10. async { loop {} }
  11. // Box::pin(async { loop {} }) as Pin<Box<dyn Future<Output = ()>>>
  12. },
  13. |f| f,
  14. |_| {},
  15. );
  16. // let g = unsafe { Pin::new_unchecked(fut) };
  17. // cx.submit_task(fut);
  18. todo!()
  19. };
  20. const Task: FC<()> = |cx| {
  21. //
  22. let s = cx.use_task(|| async { "hello world".to_string() });
  23. todo!()
  24. };
  25. fn use_mut<P, T>(cx: Context<P>, f: impl FnOnce() -> T) -> &mut T {
  26. todo!()
  27. }