refactor(node): defer setting client until adding to scenegraph

This commit is contained in:
Nova
2022-06-14 18:18:22 -04:00
parent beaa3d0e6b
commit 651fa5f012
4 changed files with 11 additions and 30 deletions

View File

@@ -18,7 +18,7 @@ pub type Method = fn(&Node, Rc<Client>, &[u8]) -> Result<Vec<u8>>;
pub struct Node {
uid: String,
client: Weak<Client>,
pub(crate) client: Weak<Client>,
path: String,
// trailing_slash_pos: usize,
local_signals: HashMap<String, Signal, BuildHasherDefault<FxHasher>>,
@@ -45,13 +45,13 @@ impl Node {
self.destroyable
}
pub fn create(client: Weak<Client>, parent: &str, name: &str, destroyable: bool) -> Self {
pub fn create(parent: &str, name: &str, destroyable: bool) -> Self {
let mut path = parent.to_string();
path.push('/');
path.push_str(name);
let mut node = Node {
uid: nanoid!(),
client,
client: Weak::new(),
path,
// trailing_slash_pos: parent.len(),
local_signals: Default::default(),