https://github.com/heapwolf/eventemitter
Rust event emitter
https://github.com/heapwolf/eventemitter
Last synced: 12 months ago
JSON representation
Rust event emitter
- Host: GitHub
- URL: https://github.com/heapwolf/eventemitter
- Owner: heapwolf
- Created: 2020-05-10T22:13:34.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-11T13:40:39.000Z (about 6 years ago)
- Last Synced: 2025-03-29T19:11:12.554Z (about 1 year ago)
- Language: Rust
- Size: 3.91 KB
- Stars: 12
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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 });
}
```