WIP: Make the item module compile again

This commit is contained in:
Antonio Scandurra
2023-10-31 13:56:48 +01:00
parent e8eea52d0f
commit 14a6199b4b
6 changed files with 478 additions and 521 deletions
+10 -6
View File
@@ -14,7 +14,7 @@ pub use test_context::*;
use crate::{
current_platform, image_cache::ImageCache, Action, AnyBox, AnyView, AnyWindowHandle,
AppMetadata, AssetSource, ClipboardItem, Context, DispatchPhase, DisplayId, Executor,
AppMetadata, AssetSource, ClipboardItem, Context, DispatchPhase, DisplayId, Entity, Executor,
FocusEvent, FocusHandle, FocusId, KeyBinding, Keymap, LayoutId, MainThread, MainThreadOnly,
Pixels, Platform, Point, Render, SharedString, SubscriberSet, Subscription, SvgRenderer, Task,
TextStyle, TextStyleRefinement, TextSystem, View, ViewContext, Window, WindowContext,
@@ -694,13 +694,17 @@ impl AppContext {
self.globals_by_type.insert(global_type, lease.global);
}
pub fn observe_release<E: 'static>(
pub fn observe_release<E, T>(
&mut self,
handle: &Model<E>,
mut on_release: impl FnMut(&mut E, &mut AppContext) + Send + 'static,
) -> Subscription {
handle: &E,
mut on_release: impl FnMut(&mut T, &mut AppContext) + Send + 'static,
) -> Subscription
where
E: Entity<T>,
T: 'static,
{
self.release_listeners.insert(
handle.entity_id,
handle.entity_id(),
Box::new(move |entity, cx| {
let entity = entity.downcast_mut().expect("invalid entity type");
on_release(entity, cx)
+1 -1
View File
@@ -314,7 +314,7 @@ impl AnyView {
.map_err(|_| self)
}
pub(crate) fn entity_type(&self) -> TypeId {
pub fn entity_type(&self) -> TypeId {
self.0.entity_type()
}