Checkpoint
This commit is contained in:
parent
9aaf7d0c46
commit
11953e613b
12 changed files with 507 additions and 404 deletions
|
@ -163,10 +163,11 @@ impl App {
|
|||
|
||||
type ActionBuilder = fn(json: Option<serde_json::Value>) -> anyhow::Result<Box<dyn Action>>;
|
||||
type FrameCallback = Box<dyn FnOnce(&mut WindowContext) + Send>;
|
||||
type Handler = Box<dyn Fn(&mut AppContext) -> bool + Send + Sync + 'static>;
|
||||
type Listener = Box<dyn Fn(&dyn Any, &mut AppContext) -> bool + Send + Sync + 'static>;
|
||||
type QuitHandler = Box<dyn Fn(&mut AppContext) -> BoxFuture<'static, ()> + Send + Sync + 'static>;
|
||||
type ReleaseListener = Box<dyn Fn(&mut dyn Any, &mut AppContext) + Send + Sync + 'static>;
|
||||
type Handler = Box<dyn FnMut(&mut AppContext) -> bool + Send + Sync + 'static>;
|
||||
type Listener = Box<dyn FnMut(&dyn Any, &mut AppContext) -> bool + Send + Sync + 'static>;
|
||||
type QuitHandler =
|
||||
Box<dyn FnMut(&mut AppContext) -> BoxFuture<'static, ()> + Send + Sync + 'static>;
|
||||
type ReleaseListener = Box<dyn FnMut(&mut dyn Any, &mut AppContext) + Send + Sync + 'static>;
|
||||
|
||||
pub struct AppContext {
|
||||
this: Weak<Mutex<AppContext>>,
|
||||
|
@ -355,7 +356,7 @@ impl AppContext {
|
|||
for (entity_id, mut entity) in dropped {
|
||||
self.observers.remove(&entity_id);
|
||||
self.event_listeners.remove(&entity_id);
|
||||
for release_callback in self.release_listeners.remove(&entity_id) {
|
||||
for mut release_callback in self.release_listeners.remove(&entity_id) {
|
||||
release_callback(&mut entity, self);
|
||||
}
|
||||
}
|
||||
|
@ -571,7 +572,7 @@ impl AppContext {
|
|||
|
||||
pub fn observe_global<G: 'static>(
|
||||
&mut self,
|
||||
f: impl Fn(&mut Self) + Send + Sync + 'static,
|
||||
mut f: impl FnMut(&mut Self) + Send + Sync + 'static,
|
||||
) -> Subscription {
|
||||
self.global_observers.insert(
|
||||
TypeId::of::<G>(),
|
||||
|
|
|
@ -43,7 +43,7 @@ impl<'a, T: 'static> ModelContext<'a, T> {
|
|||
pub fn observe<T2: 'static>(
|
||||
&mut self,
|
||||
handle: &Handle<T2>,
|
||||
on_notify: impl Fn(&mut T, Handle<T2>, &mut ModelContext<'_, T>) + Send + Sync + 'static,
|
||||
mut on_notify: impl FnMut(&mut T, Handle<T2>, &mut ModelContext<'_, T>) + Send + Sync + 'static,
|
||||
) -> Subscription
|
||||
where
|
||||
T: Any + Send + Sync,
|
||||
|
@ -66,7 +66,7 @@ impl<'a, T: 'static> ModelContext<'a, T> {
|
|||
pub fn subscribe<E: 'static + EventEmitter>(
|
||||
&mut self,
|
||||
handle: &Handle<E>,
|
||||
on_event: impl Fn(&mut T, Handle<E>, &E::Event, &mut ModelContext<'_, T>)
|
||||
mut on_event: impl FnMut(&mut T, Handle<E>, &E::Event, &mut ModelContext<'_, T>)
|
||||
+ Send
|
||||
+ Sync
|
||||
+ 'static,
|
||||
|
@ -92,7 +92,7 @@ impl<'a, T: 'static> ModelContext<'a, T> {
|
|||
|
||||
pub fn on_release(
|
||||
&mut self,
|
||||
on_release: impl Fn(&mut T, &mut AppContext) + Send + Sync + 'static,
|
||||
mut on_release: impl FnMut(&mut T, &mut AppContext) + Send + Sync + 'static,
|
||||
) -> Subscription
|
||||
where
|
||||
T: 'static,
|
||||
|
@ -109,7 +109,7 @@ impl<'a, T: 'static> ModelContext<'a, T> {
|
|||
pub fn observe_release<E: 'static>(
|
||||
&mut self,
|
||||
handle: &Handle<E>,
|
||||
on_release: impl Fn(&mut T, &mut E, &mut ModelContext<'_, T>) + Send + Sync + 'static,
|
||||
mut on_release: impl FnMut(&mut T, &mut E, &mut ModelContext<'_, T>) + Send + Sync + 'static,
|
||||
) -> Subscription
|
||||
where
|
||||
T: Any + Send + Sync,
|
||||
|
@ -128,7 +128,7 @@ impl<'a, T: 'static> ModelContext<'a, T> {
|
|||
|
||||
pub fn observe_global<G: 'static>(
|
||||
&mut self,
|
||||
f: impl Fn(&mut T, &mut ModelContext<'_, T>) + Send + Sync + 'static,
|
||||
mut f: impl FnMut(&mut T, &mut ModelContext<'_, T>) + Send + Sync + 'static,
|
||||
) -> Subscription
|
||||
where
|
||||
T: Any + Send + Sync,
|
||||
|
@ -142,7 +142,7 @@ impl<'a, T: 'static> ModelContext<'a, T> {
|
|||
|
||||
pub fn on_app_quit<Fut>(
|
||||
&mut self,
|
||||
on_quit: impl Fn(&mut T, &mut ModelContext<T>) -> Fut + Send + Sync + 'static,
|
||||
mut on_quit: impl FnMut(&mut T, &mut ModelContext<T>) -> Fut + Send + Sync + 'static,
|
||||
) -> Subscription
|
||||
where
|
||||
Fut: 'static + Future<Output = ()> + Send,
|
||||
|
|
|
@ -1418,7 +1418,10 @@ impl<'a, 'w, V: 'static> ViewContext<'a, 'w, V> {
|
|||
pub fn observe<E>(
|
||||
&mut self,
|
||||
handle: &Handle<E>,
|
||||
on_notify: impl Fn(&mut V, Handle<E>, &mut ViewContext<'_, '_, V>) + Send + Sync + 'static,
|
||||
mut on_notify: impl FnMut(&mut V, Handle<E>, &mut ViewContext<'_, '_, V>)
|
||||
+ Send
|
||||
+ Sync
|
||||
+ 'static,
|
||||
) -> Subscription
|
||||
where
|
||||
E: 'static,
|
||||
|
@ -1446,7 +1449,7 @@ impl<'a, 'w, V: 'static> ViewContext<'a, 'w, V> {
|
|||
pub fn subscribe<E: EventEmitter>(
|
||||
&mut self,
|
||||
handle: &Handle<E>,
|
||||
on_event: impl Fn(&mut V, Handle<E>, &E::Event, &mut ViewContext<'_, '_, V>)
|
||||
mut on_event: impl FnMut(&mut V, Handle<E>, &E::Event, &mut ViewContext<'_, '_, V>)
|
||||
+ Send
|
||||
+ Sync
|
||||
+ 'static,
|
||||
|
@ -1473,7 +1476,7 @@ impl<'a, 'w, V: 'static> ViewContext<'a, 'w, V> {
|
|||
|
||||
pub fn on_release(
|
||||
&mut self,
|
||||
on_release: impl Fn(&mut V, &mut WindowContext) + Send + Sync + 'static,
|
||||
mut on_release: impl FnMut(&mut V, &mut WindowContext) + Send + Sync + 'static,
|
||||
) -> Subscription {
|
||||
let window_handle = self.window.handle;
|
||||
self.app.release_listeners.insert(
|
||||
|
@ -1489,7 +1492,7 @@ impl<'a, 'w, V: 'static> ViewContext<'a, 'w, V> {
|
|||
pub fn observe_release<T: 'static>(
|
||||
&mut self,
|
||||
handle: &Handle<T>,
|
||||
on_release: impl Fn(&mut V, &mut T, &mut ViewContext<'_, '_, V>) + Send + Sync + 'static,
|
||||
mut on_release: impl FnMut(&mut V, &mut T, &mut ViewContext<'_, '_, V>) + Send + Sync + 'static,
|
||||
) -> Subscription
|
||||
where
|
||||
V: Any + Send + Sync,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue