extension: Add ExtensionEvents
for listening to extension-related events (#26562)
This PR adds a new `ExtensionEvents` event bus that can be used to listen for extension-related events throughout the app. Today you need to have a handle to the `ExtensionStore` (which entails depending on `extension_host`) in order to listen for extension events. With this change subscribers only need to depend on `extension`, which has a leaner dependency graph. Release Notes: - N/A
This commit is contained in:
parent
ffcd023f83
commit
acf9b22466
7 changed files with 57 additions and 8 deletions
|
@ -14,7 +14,7 @@ use collections::{btree_map, BTreeMap, BTreeSet, HashMap, HashSet};
|
|||
use extension::extension_builder::{CompileExtensionOptions, ExtensionBuilder};
|
||||
pub use extension::ExtensionManifest;
|
||||
use extension::{
|
||||
ExtensionContextServerProxy, ExtensionGrammarProxy, ExtensionHostProxy,
|
||||
ExtensionContextServerProxy, ExtensionEvents, ExtensionGrammarProxy, ExtensionHostProxy,
|
||||
ExtensionIndexedDocsProviderProxy, ExtensionLanguageProxy, ExtensionLanguageServerProxy,
|
||||
ExtensionSlashCommandProxy, ExtensionSnippetProxy, ExtensionThemeProxy,
|
||||
};
|
||||
|
@ -127,7 +127,6 @@ pub enum ExtensionOperation {
|
|||
|
||||
#[derive(Clone)]
|
||||
pub enum Event {
|
||||
ExtensionsUpdated,
|
||||
StartedReloading,
|
||||
ExtensionInstalled(Arc<str>),
|
||||
ExtensionFailedToLoad(Arc<str>),
|
||||
|
@ -1214,7 +1213,9 @@ impl ExtensionStore {
|
|||
|
||||
self.extension_index = new_index;
|
||||
cx.notify();
|
||||
cx.emit(Event::ExtensionsUpdated);
|
||||
ExtensionEvents::global(cx).update(cx, |this, cx| {
|
||||
this.emit(extension::Event::ExtensionsUpdated, cx)
|
||||
});
|
||||
|
||||
cx.spawn(|this, mut cx| async move {
|
||||
cx.background_spawn({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue