WIP make ECS work with reactive system

This commit is contained in:
Evan Almloff committed 2023-01-19 14:40:56 -06:00
1 parent e36874d86e
commit 1587b41829
10 files changed
+564 -685

No files matched your search

+7 -19
View File
@@ -1,17 +1,8 @@
use crate::{state::State, tree::NodeId};
use crate::tree::NodeId;
use dioxus_core::{AnyValue, BorrowedAttributeValue, ElementId};
use rustc_hash::{FxHashMap, FxHashSet};
use std::fmt::Debug;
/// The node is stored client side and stores only basic data about the node.
#[derive(Debug, Clone)]
pub struct Node<S: State<V>, V: FromAnyValue = ()> {
/// The transformed state of the node.
pub state: S,
/// The raw data for the node
pub node_data: NodeData<V>,
}
#[derive(Debug, Clone)]
pub struct NodeData<V: FromAnyValue = ()> {
/// The id of the node
@@ -38,21 +29,18 @@ pub enum NodeType<V: FromAnyValue = ()> {
Placeholder,
}
impl<S: State<V>, V: FromAnyValue> Node<S, V> {
impl<V: FromAnyValue> NodeData<V> {
pub(crate) fn new(node_type: NodeType<V>) -> Self {
Node {
state: S::default(),
node_data: NodeData {
element_id: None,
node_type,
node_id: NodeId(0),
},
NodeData {
element_id: None,
node_type,
node_id: NodeId(0),
}
}
/// get the mounted id of the node
pub fn mounted_id(&self) -> Option<ElementId> {
self.node_data.element_id
self.element_id
}
}