Remove one todo from the critical path

This commit is contained in:
Nathan Sobo 2023-10-31 21:19:32 -06:00
parent 0ecf6bde73
commit 4da8ee1e1d
2 changed files with 84 additions and 67 deletions

View file

@ -1993,6 +1993,23 @@ impl<V: 'static> WindowHandle<V> {
state_type: PhantomData,
}
}
pub fn update<R>(
&self,
cx: &mut AppContext,
update: impl FnOnce(&mut V, &mut ViewContext<V>) -> R,
) -> Result<R> {
cx.update_window(self.any_handle, |cx| {
let root_view = cx
.window
.root_view
.clone()
.unwrap()
.downcast::<V>()
.unwrap();
root_view.update(cx, update)
})
}
}
impl<V: 'static> Into<AnyWindowHandle> for WindowHandle<V> {