| Crates.io | hey_listen |
| lib.rs | hey_listen |
| version | 0.5.0 |
| created_at | 2018-01-02 15:19:40.29867+00 |
| updated_at | 2021-04-18 19:49:02.164844+00 |
| description | An event-dispatcher-collection offering async, sync, parallel, and prioritised solutions! |
| homepage | |
| repository | https://github.com/lakelezz/hey_listen.git |
| max_upload_size | |
| id | 45230 |
| size | 92,831 |
Hey_listen is a collection of event-dispatchers aiming to suit all needs!
Currently covering:
View the examples-folder on how to use each dispatcher.
Everyone is welcome to contribute, check out the CONTRIBUTING.md for further guidance.
Here is a quick example on how to use the event-dispatcher:
use hey_listen::sync::{
ParallelDispatcher, ParallelListener, ParallelDispatchResult,
};
#[derive(Clone, Eq, Hash, PartialEq)]
enum Event {
Variant,
}
struct Listener {}
impl ParallelListener<Event> for Listener {
fn on_event(&self, _event: &Event) -> Option<ParallelDispatchResult> {
println!("I'm listening! :)");
None
}
}
fn main() {
let listener = Listener {};
let mut dispatcher = ParallelDispatcher::<Event>::new(4).expect("Could not construct threadpool");
dispatcher.add_listener(Event::Variant, listener);
dispatcher.dispatch_event(&Event::Variant);
}
Add this to your Cargo.toml:
[dependencies]
hey_listen = "0.5"