checkpoint

This commit is contained in:
Mikayla 2023-11-08 23:16:04 -08:00
parent f569628088
commit 43eb7f28d1
No known key found for this signature in database
22 changed files with 591 additions and 1307 deletions

View file

@ -1008,11 +1008,14 @@ impl Context for AppContext {
read(entity, self)
}
fn read_window<R>(
fn read_window<T, R>(
&self,
window: &AnyWindowHandle,
read: impl FnOnce(AnyView, &AppContext) -> R,
) -> Result<R> {
window: &WindowHandle<T>,
read: impl FnOnce(&T, &AppContext) -> R,
) -> Result<R>
where
T: 'static,
{
let window = self
.windows
.get(window.id)
@ -1021,7 +1024,11 @@ impl Context for AppContext {
.unwrap();
let root_view = window.root_view.clone().unwrap();
Ok(read(root_view, self))
let view = root_view
.downcast::<T>()
.map_err(|_| anyhow!("root view's type has changed"))?;
Ok(read(view.read(self), self))
}
}