This commit is contained in:
Antonio Scandurra 2023-10-04 20:09:55 +02:00
parent d28c81571c
commit ebc80597d5
2 changed files with 33 additions and 7 deletions

View file

@ -225,6 +225,18 @@ impl AppContext {
})
}
pub fn spawn<Fut, R>(&self, f: impl FnOnce(&mut AppContext) -> Fut + Send + 'static) -> Task<R>
where
Fut: Future<Output = R> + Send + 'static,
R: Send + 'static,
{
let this = self.this.upgrade().unwrap();
self.executor.spawn(async move {
let future = f(&mut this.lock());
future.await
})
}
pub fn text_system(&self) -> &Arc<TextSystem> {
&self.text_system
}