mirror of
https://github.com/DioxusLabs/dioxus
synced 2025-02-16 21:58:25 +00:00
clean up node mut api
This commit is contained in:
parent
0f6eb4fca2
commit
5b822201f7
2 changed files with 11 additions and 2 deletions
|
@ -420,6 +420,11 @@ impl<'a, V: FromAnyValue + Send + Sync> NodeMut<'a, V> {
|
|||
self.dom
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn parent_mut(&mut self) -> Option<NodeMut<V>> {
|
||||
self.parent_id().map(|id| NodeMut { id, dom: self.dom })
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_mut<T: Any + Sync + Send>(&mut self) -> Option<&mut T> {
|
||||
// mark the node state as dirty
|
||||
|
|
|
@ -75,7 +75,11 @@ impl TuiContext {
|
|||
|
||||
pub fn render<R: Renderer<Rc<EventData>>>(
|
||||
cfg: Config,
|
||||
f: impl FnOnce(&Arc<RwLock<RealDom>>, &Arc<Mutex<Taffy>>, UnboundedSender<InputEvent>) -> R,
|
||||
create_renderer: impl FnOnce(
|
||||
&Arc<RwLock<RealDom>>,
|
||||
&Arc<Mutex<Taffy>>,
|
||||
UnboundedSender<InputEvent>,
|
||||
) -> R,
|
||||
) -> Result<()> {
|
||||
let mut rdom = RealDom::new(Box::new([
|
||||
TaffyLayout::to_type_erased(),
|
||||
|
@ -105,7 +109,7 @@ pub fn render<R: Renderer<Rc<EventData>>>(
|
|||
|
||||
let rdom = Arc::new(RwLock::new(rdom));
|
||||
let taffy = Arc::new(Mutex::new(Taffy::new()));
|
||||
let mut renderer = f(&rdom, &taffy, event_tx_clone);
|
||||
let mut renderer = create_renderer(&rdom, &taffy, event_tx_clone);
|
||||
|
||||
{
|
||||
let mut rdom = rdom.write().unwrap();
|
||||
|
|
Loading…
Add table
Reference in a new issue