#events #dispatcher #problem #async #slow-receiver #susceptible

async-event-dispatch

A simple async event dispatcher that is not susceptible to the slow-receiver problem

1 unstable release

0.1.1 May 11, 2023

#19 in #dispatcher

30 downloads per month

MIT license

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