1 unstable release
0.1.1 | May 11, 2023 |
---|
#19 in #dispatcher
30 downloads per month
8KB
195 lines
async-event-dispatch
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;
Features
Dependencies
~2.4–4MB
~66K SLoC