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

@ -1,14 +1,14 @@
use crate::{
image_cache::RenderImageParams, px, AnyView, AppContext, AvailableSpace, BorrowAppContext,
Bounds, Context, Corners, DevicePixels, Effect, Element, EntityId, FontId, GlyphId, Handle,
Hsla, ImageData, IsZero, LayerId, LayoutId, MainThread, MainThreadOnly, MonochromeSprite,
Pixels, PlatformAtlas, PlatformWindow, Point, PolychromeSprite, Reference, RenderGlyphParams,
RenderSvgParams, ScaledPixels, Scene, SharedString, Size, Style, TaffyLayoutEngine, Task,
WeakHandle, WindowOptions, SUBPIXEL_VARIANTS,
image_cache::RenderImageParams, px, AnyView, AppContext, AsyncContext, AvailableSpace,
BorrowAppContext, Bounds, Context, Corners, DevicePixels, Effect, Element, EntityId, FontId,
GlyphId, Handle, Hsla, ImageData, IsZero, LayerId, LayoutId, MainThread, MainThreadOnly,
MonochromeSprite, Pixels, PlatformAtlas, PlatformWindow, Point, PolychromeSprite, Reference,
RenderGlyphParams, RenderSvgParams, ScaledPixels, Scene, SharedString, Size, Style,
TaffyLayoutEngine, Task, WeakHandle, WindowOptions, SUBPIXEL_VARIANTS,
};
use anyhow::Result;
use smallvec::SmallVec;
use std::{any::TypeId, borrow::Cow, marker::PhantomData, mem, sync::Arc};
use std::{any::TypeId, borrow::Cow, future::Future, marker::PhantomData, mem, sync::Arc};
use util::ResultExt;
pub struct AnyWindow {}
@ -601,6 +601,20 @@ impl<'a, 'w, S: Send + Sync + 'static> ViewContext<'a, 'w, S> {
}
}
pub fn spawn<Fut, R>(
&mut self,
f: impl FnOnce(&mut S, &mut ViewContext<'_, '_, S>) -> Fut + Send + 'static,
) -> Task<Result<R>>
where
Fut: Future<Output = R> + Send + 'static,
{
let handle = self.handle();
todo!()
// self.window_cx.spawn(|cx| {
// f
// })
}
pub(crate) fn erase_state<R>(&mut self, f: impl FnOnce(&mut ViewContext<()>) -> R) -> R {
let entity_id = self.unit_entity.id;
let mut cx = ViewContext::mutable(