Expand description
Event system for LightyLauncher
Simple broadcast-based event system that allows emitting events from the library and subscribing to them from user code.
§Example
use lighty_event::{EventBus, Event, LaunchEvent, EventReceiveError};
#[tokio::main]
async fn main() {
let event_bus = EventBus::new(100);
let mut receiver = event_bus.subscribe();
// Spawn a listener with error handling
tokio::spawn(async move {
loop {
match receiver.next().await {
Ok(event) => {
match event {
Event::Launch(LaunchEvent::InstallProgress { bytes }) => {
println!("Downloaded {} bytes", bytes);
}
_ => {}
}
}
Err(EventReceiveError::BusDropped) => {
println!("Event bus closed");
break;
}
Err(EventReceiveError::Lagged { skipped }) => {
eprintln!("Receiver lagged, missed {} events", skipped);
}
}
}
});
// Use the launcher with event_bus...
}Re-exports§
pub use module::AuthEvent;pub use module::CoreEvent;pub use module::JavaEvent;pub use module::LaunchEvent;pub use module::LoaderEvent;
Modules§
- module
- Event modules for different components
Structs§
- Event
Bus - Event bus for broadcasting events to multiple listeners
- Event
Receiver - Receiver for events from an EventBus
Enums§
- Event
- Root event enum containing all event types
- Event
Receive Error - Errors that can occur when receiving events
- Event
Send Error - Errors that can occur when sending events
- Event
TryReceive Error - Errors that can occur when trying to receive events (non-blocking)
Type Aliases§
- Event
Receive Result - Type alias for event receive operations
- Event
Send Result - Type alias for event send operations
- Event
TryReceive Result - Type alias for event try receive operations