EventSource
Zero cost non buffered async event emitter
This crate is no_std
Features
- Non buffered, immediate event dispatch
- Zero cost listener adding, removing
- Higher kinded event type
- Propagation control
Example
async fn main() {
let source: Arc<EventSource!(&mut i32)> = Arc::new(EventSource::new());
spawn({
let source = source.clone();
async {
let mut a = 35;
emit!(source, &mut a);
}
});
let mut output = 0;
source.on(|value, flow| {
println!("Event emiited with value: {}!", value);
output = *value;
flow.set_done();
}).await;
println!("Output: {}", output);
}
Output
Event emiited with value: 35!
Output: 35
License
MIT