Crates.io | async-event-dispatch |
lib.rs | async-event-dispatch |
version | 0.1.1 |
source | src |
created_at | 2023-05-11 21:08:32.588005 |
updated_at | 2023-05-11 21:08:32.588005 |
description | A simple async event dispatcher that is not susceptible to the slow-receiver problem |
homepage | |
repository | |
max_upload_size | |
id | 862453 |
size | 9,023 |
A simple event dispatcher for Rust that is not susceptible to the slow-receiver problem.
#[derive(Clone)]
struct MyEvent(String);
let dispatcher = Dispatcher::<MyEvent>::new();
let subscriber = dispatcher.subscribe().await;
tokio::spawn(async move {
while let Some(event) = subscriber.next().await {
println!("Event: {}", event.0);
}
})
dispatcher.dispatch(MyEvent("Hello World!".into())).await;