This commit is contained in:
Nathan Sobo
2021-09-14 12:29:56 -06:00
parent 428c491542
commit f0019e3725
8 changed files with 135 additions and 31 deletions
+10
View File
@@ -2282,6 +2282,16 @@ impl<'a, T: View> ViewContext<'a, T> {
let handle = self.handle();
self.app.spawn(|cx| f(handle, cx))
}
pub fn spawn_weak<F, Fut, S>(&self, f: F) -> Task<S>
where
F: FnOnce(WeakViewHandle<T>, AsyncAppContext) -> Fut,
Fut: 'static + Future<Output = S>,
S: 'static,
{
let handle = self.handle().downgrade();
self.app.spawn(|cx| f(handle, cx))
}
}
pub struct RenderContext<'a, T: View> {