lib.rs 718 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. mod usestate;
  2. pub use usestate::{use_state, UseState};
  3. mod useref;
  4. pub use useref::*;
  5. mod use_shared_state;
  6. pub use use_shared_state::*;
  7. mod usecoroutine;
  8. pub use usecoroutine::*;
  9. mod usefuture;
  10. pub use usefuture::*;
  11. mod usecallback;
  12. pub use usecallback::*;
  13. mod useeffect;
  14. pub use useeffect::*;
  15. #[macro_export]
  16. /// A helper macro for using hooks in async environements.
  17. ///
  18. /// # Usage
  19. ///
  20. ///
  21. /// ```
  22. /// let (data) = use_ref(&cx, || {});
  23. ///
  24. /// let handle_thing = move |_| {
  25. /// to_owned![data]
  26. /// cx.spawn(async move {
  27. /// // do stuff
  28. /// });
  29. /// }
  30. /// ```
  31. macro_rules! to_owned {
  32. ($($es:ident),+) => {$(
  33. #[allow(unused_mut)]
  34. let mut $es = $es.to_owned();
  35. )*}
  36. }