reactive_graph_std_trigger/
plugin.rs

1use reactive_graph_plugin_api::ComponentProviderRegistry;
2use reactive_graph_plugin_api::prelude::plugin::*;
3
4export_plugin!({
5  "dependencies": [
6    {
7      "name": "reactive-graph-std-base",
8      "version": ">=0.10.0, <0.11.0"
9    }
10  ]
11});
12
13#[injectable]
14pub trait TriggerPlugin: Plugin + Send + Sync {}
15
16#[derive(Component)]
17pub struct TriggerPluginImpl {
18    component_provider: Arc<dyn TypeProvider<Components> + Send + Sync>,
19
20    #[component(default = "component_provider_registry")]
21    component_provider_registry: Arc<dyn ComponentProviderRegistry + Send + Sync>,
22}
23
24#[async_trait]
25#[component_alias]
26impl Plugin for TriggerPluginImpl {
27    async fn activate(&self) -> Result<(), PluginActivationError> {
28        self.component_provider_registry.register_provider(self.component_provider.clone()).await;
29        Ok(())
30    }
31
32    async fn deactivate(&self) -> Result<(), PluginDeactivationError> {
33        self.component_provider_registry.unregister_provider(self.component_provider.id()).await;
34        Ok(())
35    }
36}