Skip to content

Commit

Permalink
Put register code in separate function
Browse files Browse the repository at this point in the history
  • Loading branch information
Leinnan committed Feb 14, 2024
1 parent 37421ec commit 57d3418
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bevy_forge/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn main() {
DefaultPlugins,
DebugPlugin,
BeamPlugin,
microservice::RequestSayHiPlugin,
microservice::MicroservicePlugin,
))
// Never attempts to look up meta files. The default meta configuration will be used for each asset.
.insert_resource(AssetMetaCheck::Never)
Expand Down
16 changes: 11 additions & 5 deletions bevy_forge/src/microservice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,25 @@ use bevy::{prelude::*, tasks::IoTaskPool};
#[cfg(target_family = "wasm")]
use crossbeam_channel::{bounded, Receiver};

pub struct RequestSayHiPlugin;
pub struct MicroservicePlugin;

impl Plugin for RequestSayHiPlugin {
impl Plugin for MicroservicePlugin {
fn build(&self, app: &mut App) {
app.add_event::<RequestSayHiEvent>()
.add_event::<RequestSayHiEventCompleted>()
.add_systems(Update, (request, handle_request));
RequestSayHiEvent::register(app);
}
}

#[derive(Event, Deref, DerefMut)]
pub struct RequestSayHiEvent(pub models::SayHiRequestArgs);

impl RequestSayHiEvent {
pub fn register(app: &mut App) {
app.add_event::<RequestSayHiEvent>()
.add_event::<RequestSayHiEventCompleted>()
.add_systems(Update, (request, handle_request));
}
}

#[derive(Event, Deref, DerefMut)]
pub struct RequestSayHiEventCompleted(
pub Result<String, beam_microservice::apis::Error<SayHiPostError>>,
Expand Down

0 comments on commit 57d3418

Please sign in to comment.