Return Result from AsyncAppContext::update_view

This commit is contained in:
Antonio Scandurra 2023-04-18 12:03:53 +02:00
parent 493a418c91
commit 31e6bb4fc1
4 changed files with 62 additions and 56 deletions

View file

@ -464,19 +464,20 @@ impl ReadModelWith for AsyncAppContext {
}
impl UpdateView for AsyncAppContext {
type Output<S> = Option<S>;
type Output<S> = Result<S>;
fn update_view<T, S>(
&mut self,
handle: &ViewHandle<T>,
update: &mut dyn FnMut(&mut T, &mut ViewContext<T>) -> S,
) -> Option<S>
) -> Result<S>
where
T: View,
{
self.0
.borrow_mut()
.update_window(handle.window_id, |cx| cx.update_view(handle, update))
.ok_or_else(|| anyhow!("window was closed"))
}
}