Skip to content

Commit

Permalink
cleanup: no need to do component registration yet
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanceras committed Mar 7, 2024
1 parent 4566185 commit cdca023
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions crates/core/src/dom/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ where
/// generic closures that has no argument
pub closures: Rc<RefCell<Closures>>,
last_update: Rc<RefCell<Option<f64>>>,
pub components: Rc<RefCell<BTreeMap<usize, Box<dyn StatefulComponent>>>>,
}

pub struct WeakProgram<APP, MSG>
Expand All @@ -92,7 +91,6 @@ where
pub(crate) event_closures: Weak<RefCell<EventClosures>>,
pub(crate) closures: Weak<RefCell<Closures>>,
last_update: Weak<RefCell<Option<f64>>>,
pub components: Weak<RefCell<BTreeMap<usize, Box<dyn StatefulComponent>>>>,
}

/// Closures that we are holding on to to make sure that they don't get invalidated after a
Expand Down Expand Up @@ -146,7 +144,6 @@ where
let event_closures = self.event_closures.upgrade()?;
let closures = self.closures.upgrade()?;
let last_update = self.last_update.upgrade()?;
let components = self.components.upgrade()?;
Some(Program {
app_context,
root_node,
Expand All @@ -159,7 +156,6 @@ where
event_closures,
closures,
last_update,
components,
})
}
}
Expand All @@ -181,7 +177,6 @@ where
event_closures: Weak::clone(&self.event_closures),
closures: Weak::clone(&self.closures),
last_update: Weak::clone(&self.last_update),
components: Weak::clone(&self.components),
}
}
}
Expand All @@ -204,22 +199,9 @@ where
event_closures: Rc::downgrade(&self.event_closures),
closures: Rc::downgrade(&self.closures),
last_update: Rc::downgrade(&self.last_update),
components: Rc::downgrade(&self.components),
}
}

pub fn register_component<COMP>(&mut self)
where
COMP: StatefulComponent + 'static,
{
let comp = COMP::build([], []);
let comp_id = create_component_unique_identifier();
let template = comp.template();
//let template = extract_template(&comp.view());
let comp_name = std::any::type_name::<COMP>();
//log::info!("template of component: {comp_name}:\n{}", template.render_to_string());
self.components.borrow_mut().insert(comp_id, Box::new(comp));
}
}

impl<APP, MSG> Clone for Program<APP, MSG>
Expand All @@ -239,7 +221,6 @@ where
event_closures: Rc::clone(&self.event_closures),
closures: Rc::clone(&self.closures),
last_update: Rc::clone(&self.last_update),
components: Rc::clone(&self.components),
}
}
}
Expand Down Expand Up @@ -284,7 +265,6 @@ where
event_closures: Rc::new(RefCell::new(vec![])),
closures: Rc::new(RefCell::new(vec![])),
last_update: Rc::new(RefCell::new(None)),
components: Rc::new(RefCell::new(BTreeMap::new())),
}
}

Expand Down

0 comments on commit cdca023

Please sign in to comment.