simpleeventmap

This allows you to register types that'll be broadcast to receivers

An example

```rust

[derive(Clone, Debug, PartialEq)]

struct Message { data: String }

let mut map = EventMap::new(); // nothing is registered by default asserteq!(map.isempty::(), true); asserteq!(map.isempty::(), true); asserteq!(map.isempty::(), true);

// register two subscriptions for the message // you can get a blocking iterator let mut m1 = map.registeriter::(); // or you can get an async stream let mut m2 = map.registerstream::();

let msg = Message{ data: String::from("hello world") }; // send the message, will return a bool if any messages were sent asserteq!(map.send(msg.clone()), true); // we should have 2 still active asserteq!(map.active::(), 2);

asserteq!(m1.next().unwrap(), msg); // m2 is a stream, so we have to await it (and use StreamExt::next) asserteq!(m2.next().await.unwrap(), msg);

// drop a subscription (will be cleaned up in the eventmap on next send) drop(m1);

let msg = Message{ data: String::from("testing") }; asserteq!(map.send(msg.clone()), true); // we only have 1 active now asserteq!(map.active::(), 1); ```

License

simple_event_map is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.