An open API service indexing awesome lists of open source software.

https://github.com/heapwolf/eventemitter

Rust event emitter
https://github.com/heapwolf/eventemitter

Last synced: 12 months ago
JSON representation

Rust event emitter

Awesome Lists containing this project

README

          

# SYNOPSIS
An event emtter for Rust.

# USAGE

```rust
mod events;

fn main () {
let mut e = events::EventEmitter::new();

e.on("click", |data: &mut dyn Any| {

//
// Listen for any data structure and re-cast it.
//
let d = &mut data.downcast_mut::().unwrap();
assert_eq!(d.x, 1);
});

struct Args {
pub x: usize,
pub y: usize,
}

//
// Emit any data structure
//
e.emit("click", &mut Args { x: 1, y: 2 });
}
```