reactive_graph_std_flow/
plugin.rs1use reactive_graph_plugin_api::prelude::plugin::*;
2use reactive_graph_plugin_api::prelude::providers::*;
3
4export_plugin!({
5 "dependencies": [
6 { "name": "reactive-graph-std-base", "version": ">=0.10.0, <0.11.0" }
7 ]
8});
9
10#[injectable]
11pub trait FlowPlugin: Plugin + Send + Sync {}
12
13#[derive(Component)]
14pub struct FlowPluginImpl {
15 component_provider: Arc<dyn TypeProvider<Components> + Send + Sync>,
16
17 #[component(default = "component_provider_registry")]
18 component_provider_registry: Arc<dyn ComponentProviderRegistry + Send + Sync>,
19
20 entity_types_provider: Arc<dyn TypeProvider<EntityTypes> + Send + Sync>,
21
22 #[component(default = "entity_types_provider_registry")]
23 entity_type_provider_registry: Arc<dyn EntityTypeProviderRegistry + Send + Sync>,
24
25 flow_types_provider: Arc<dyn TypeProvider<FlowTypes> + Send + Sync>,
26
27 #[component(default = "flow_types_provider_registry")]
28 flow_type_provider_registry: Arc<dyn FlowTypeProviderRegistry + Send + Sync>,
29}
30
31#[async_trait]
32#[component_alias]
33impl Plugin for FlowPluginImpl {
34 async fn activate(&self) -> Result<(), PluginActivationError> {
35 self.component_provider_registry.register_provider(self.component_provider.clone()).await;
36 self.entity_type_provider_registry.register_provider(self.entity_types_provider.clone()).await;
37 self.flow_type_provider_registry.register_provider(self.flow_types_provider.clone()).await;
38 Ok(())
39 }
40
41 async fn deactivate(&self) -> Result<(), PluginDeactivationError> {
42 self.flow_type_provider_registry.unregister_provider(self.flow_types_provider.id()).await;
43 self.entity_type_provider_registry.unregister_provider(self.entity_types_provider.id()).await;
44 self.component_provider_registry.unregister_provider(self.component_provider.id()).await;
45 Ok(())
46 }
47}