@@ -1084,9 +1084,9 @@ impl MutableAppContext {
})
}
- pub fn global_subscribe<E, F>(&mut self, mut callback: F) -> Subscription
+ pub fn subscribe_global<E, F>(&mut self, mut callback: F) -> Subscription
where
- E: Any + Copy,
+ E: Any,
F: 'static + FnMut(&E, &mut Self),
{
let id = post_inc(&mut self.next_subscription_id);
@@ -1096,19 +1096,19 @@ impl MutableAppContext {
.entry(type_id)
.or_default()
.insert(
- id,
+ id,
Box::new(move |payload, cx| {
let payload = payload.downcast_ref().expect("downcast is type safe");
callback(payload, cx)
- }));
+ }),
+ );
Subscription::GlobalSubscription {
id,
type_id,
- subscriptions: Some(Arc::downgrade(&self.global_subscriptions))
+ subscriptions: Some(Arc::downgrade(&self.global_subscriptions)),
}
}
-
pub fn observe<E, H, F>(&mut self, handle: &H, mut callback: F) -> Subscription
where
E: Entity,
@@ -3817,7 +3817,8 @@ pub enum Subscription {
GlobalSubscription {
id: usize,
type_id: TypeId,
- subscriptions: Option<Weak<Mutex<HashMap<TypeId, BTreeMap<usize, GlobalSubscriptionCallback>>>>>,
+ subscriptions:
+ Option<Weak<Mutex<HashMap<TypeId, BTreeMap<usize, GlobalSubscriptionCallback>>>>>,
},
Observation {
id: usize,
@@ -1511,7 +1511,7 @@ fn open(action: &Open, cx: &mut MutableAppContext) {
.detach();
}
-pub struct WorkspaceBuilt(WeakViewHandle<Workspace>);
+pub struct WorkspaceCreated(WeakViewHandle<Workspace>);
pub fn open_paths(
abs_paths: &[PathBuf],
@@ -1549,7 +1549,7 @@ pub fn open_paths(
);
(app_state.build_workspace)(project, &app_state, cx)
});
- cx.emit_global(WorkspaceBuilt(workspace.downgrade()));
+ cx.emit_global(WorkspaceCreated(workspace.downgrade()));
workspace
});
@@ -1588,7 +1588,7 @@ pub fn join_project(
let (_, workspace) = cx.add_window((app_state.build_window_options)(), |cx| {
(app_state.build_workspace)(project, &app_state, cx)
});
- cx.emit_global(WorkspaceBuilt(workspace.downgrade()));
+ cx.emit_global(WorkspaceCreated(workspace.downgrade()));
workspace
}))
})
@@ -1605,6 +1605,6 @@ fn open_new(app_state: &Arc<AppState>, cx: &mut MutableAppContext) {
);
(app_state.build_workspace)(project, &app_state, cx)
});
- cx.emit_global(WorkspaceBuilt(workspace.downgrade()));
+ cx.emit_global(WorkspaceCreated(workspace.downgrade()));
cx.dispatch_action(window_id, vec![workspace.id()], &OpenNew(app_state.clone()));
}