diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index 37b73b9ca0..31efb4991e 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -2938,6 +2938,17 @@ impl ViewHandle { }) } + pub fn defer(&self, cx: &mut C, update: F) + where + C: AsMut, + F: 'static + FnOnce(&mut T, &mut ViewContext), + { + let this = self.clone(); + cx.as_mut().defer(Box::new(move |cx| { + this.update(cx, |view, cx| update(view, cx)); + })); + } + pub fn is_focused(&self, cx: &AppContext) -> bool { cx.focused_view_id(self.window_id) .map_or(false, |focused_id| focused_id == self.view_id)