reactive_graph_std_base/
plugin.rs

1use reactive_graph_plugin_api::prelude::plugin::*;
2use reactive_graph_plugin_api::prelude::providers::*;
3
4export_plugin!();
5
6#[derive(Component)]
7pub struct BasePluginImpl {
8    component_provider: Arc<dyn TypeProvider<Components> + Send + Sync>,
9
10    #[component(default = "component_provider_registry")]
11    component_provider_registry: Arc<dyn ComponentProviderRegistry + Send + Sync>,
12}
13
14#[async_trait]
15#[component_alias]
16impl Plugin for BasePluginImpl {
17    async fn activate(&self) -> Result<(), PluginActivationError> {
18        self.component_provider_registry.register_provider(self.component_provider.clone()).await;
19        Ok(())
20    }
21
22    async fn deactivate(&self) -> Result<(), PluginDeactivationError> {
23        self.component_provider_registry.unregister_provider(self.component_provider.id()).await;
24        Ok(())
25    }
26}