fermi.rs 860 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #![allow(non_snake_case)]
  2. use dioxus::prelude::*;
  3. use fermi::*;
  4. #[test]
  5. fn test_fermi() {
  6. let mut app = VirtualDom::new(App);
  7. app.rebuild();
  8. }
  9. static TITLE: Atom<String> = |_| "".to_string();
  10. static USERS: AtomFamily<u32, String> = |_| Default::default();
  11. fn App(cx: Scope) -> Element {
  12. cx.render(rsx!(
  13. Leaf { id: 0 }
  14. Leaf { id: 1 }
  15. Leaf { id: 2 }
  16. ))
  17. }
  18. #[derive(Debug, PartialEq, Props)]
  19. struct LeafProps {
  20. id: u32,
  21. }
  22. fn Leaf(cx: Scope<LeafProps>) -> Element {
  23. let _user = use_read(&cx, TITLE);
  24. let _user = use_read(&cx, USERS);
  25. rsx!(cx, div {
  26. button {
  27. onclick: move |_| {},
  28. "Start"
  29. }
  30. button {
  31. onclick: move |_| {},
  32. "Stop"
  33. }
  34. button {
  35. onclick: move |_| {},
  36. "Reverse"
  37. }
  38. })
  39. }