parse.rs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. use dioxus_native_core::real_dom_new_api::*;
  2. use dioxus_native_core_macro::*;
  3. #[derive(State)]
  4. struct Z {
  5. // depends on just attributes and no context
  6. #[node_dep_state()]
  7. x: A,
  8. // depends on attributes, the B component of children and i32 context
  9. #[child_dep_state(i32, B)]
  10. y: B,
  11. // depends on attributes, the C component of it's parent and a u8 context
  12. #[parent_dep_state(u8, C)]
  13. z: C,
  14. }
  15. // struct Z {
  16. // x: A,
  17. // y: B,
  18. // z: C,
  19. // }
  20. use dioxus_native_core::real_dom_new_api::NodeDepState;
  21. #[derive(PartialEq)]
  22. struct A;
  23. impl NodeDepState for A {
  24. type Ctx = ();
  25. fn reduce(&mut self, _: NodeView, _: &()) -> bool {
  26. todo!()
  27. }
  28. }
  29. #[derive(PartialEq)]
  30. struct B;
  31. impl ChildDepState for B {
  32. type Ctx = i32;
  33. type DepState = Self;
  34. fn reduce(
  35. &mut self,
  36. _: dioxus_native_core::real_dom_new_api::NodeView,
  37. _: Vec<&Self::DepState>,
  38. _: &i32,
  39. ) -> bool {
  40. todo!()
  41. }
  42. }
  43. #[derive(PartialEq)]
  44. struct C;
  45. impl ParentDepState for C {
  46. type Ctx = u8;
  47. type DepState = Self;
  48. fn reduce(
  49. &mut self,
  50. _: dioxus_native_core::real_dom_new_api::NodeView,
  51. _: &Self::DepState,
  52. _: &u8,
  53. ) -> bool {
  54. todo!()
  55. }
  56. }