crier 0.3.4

A simple but flexible observer library
Documentation
use crier::{Event, Handle, Publisher};

#[derive(Clone, Event)]
struct Info(String);

struct InfoHandler {}

impl InfoHandler {
    fn log(&self, event: Info) {
        println!("Info: {}", event.0)
    }
}

impl Handle for InfoHandler {
    type EventType = Info;

    fn handle(&self, event: Self::EventType) {
        self.log(event);
    }
}

fn main() {
    let mut publisher = Publisher::default();

    let info_handler = InfoHandler {};
    let handler_id = publisher.subscribe(info_handler);

    let _ = publisher.publish(Info(String::from("All good")));

    publisher.unsubscribe(handler_id);
}