Expand description
Hey_listen is a collection of event-dispatchers aiming to suit all needs!
Covering synchronous, parallel, and sync-prioritised dispatching to
Closures, Enums, Structs, and every other type supporting trait-implementation.
View the examples on how to use each dispatcher.
§Usage
Add this to your Cargo.toml:
[dependencies]
hey_listen = "0.5"§Example
Here is a quick example on how to use the sync event-dispatcher:
use hey_listen::sync::{
ParallelDispatcher, ParallelListener, ParallelDispatchResult,
};
#[derive(Clone, Eq, Hash, PartialEq)]
enum Event {
EventType,
}
struct ListenerStruct;
impl ParallelListener<Event> for ListenerStruct {
fn on_event(&self, event: &Event) -> Option<ParallelDispatchResult> {
println!("I'm listening! :)");
None
}
}
let listener = ListenerStruct;
let mut dispatcher: ParallelDispatcher<Event> = ParallelDispatcher::new(8).expect("Could not construct threadpool");
dispatcher.add_listener(Event::EventType, listener);
Modules§
Enums§
- Error
hey_listen’s Error collection. As long as there are no other errors, keep it locked away.