Rust implementation of observer design pattern. Dispatch is immediate and multicast. For delayed handling you can use shrev.
More information about this crate can be found in the crate documentation.
- Strongly typed
- Subscribe and unsubscribe of multiple handlers
- Configurable lifetime, mutability and thread safety constraints for handlers
To use eventd
, first add this to your Cargo.toml
:
[dependencies]
eventd = "0.3"
Next, you can use event!
macro to define your event signatures and use them:
#[macro_use]
extern crate eventd;
event!(MyEvent => Fn(x: u8) + 'static);
fn main() {
let mut my_event = MyEvent::default();
let _ = my_event.subscribe(|x| println!("Got {}", x));
my_event.emit(42);
}