Allow adding write access to guests

This commit is contained in:
Conrad Irwin 2024-01-08 16:52:20 -07:00
parent ca0c06b577
commit 844d161c40
16 changed files with 349 additions and 145 deletions

View file

@ -2,7 +2,7 @@ use crate::{Toast, Workspace};
use collections::HashMap;
use gpui::{
AnyView, AppContext, AsyncWindowContext, DismissEvent, Entity, EntityId, EventEmitter, Render,
View, ViewContext, VisualContext,
Task, View, ViewContext, VisualContext, WindowContext,
};
use std::{any::TypeId, ops::DerefMut};
@ -393,3 +393,18 @@ where
}
}
}
pub trait NotifyTaskExt {
fn detach_and_notify_err(self, cx: &mut WindowContext);
}
impl<R, E> NotifyTaskExt for Task<Result<R, E>>
where
E: std::fmt::Debug + 'static,
R: 'static,
{
fn detach_and_notify_err(self, cx: &mut WindowContext) {
cx.spawn(|mut cx| async move { self.await.notify_async_err(&mut cx) })
.detach();
}
}