#event #emitter #publish #subscribe #ee

alone_ee

Small event emitter for rapid development of weak dependency in applications. simple. powerful. predicted

23 stable releases

✓ Uses Rust 2018 edition

new 1.7.0 Jan 21, 2020
1.6.5 Jan 16, 2020
1.4.2 Dec 15, 2019
1.1.0 Nov 19, 2019
1.0.3 Oct 29, 2019

#1 in #emitter

Download history 29/week @ 2019-10-13 27/week @ 2019-10-20 31/week @ 2019-10-27 7/week @ 2019-11-03 5/week @ 2019-11-10 31/week @ 2019-11-17 24/week @ 2019-11-24 6/week @ 2019-12-01 439/week @ 2019-12-08 30/week @ 2019-12-15 19/week @ 2019-12-22 2/week @ 2019-12-29 90/week @ 2020-01-05 80/week @ 2020-01-12 61/week @ 2020-01-19

272 downloads per month

GPL-3.0 license

11KB
253 lines

alone_ee

The simplest event emitter for rust

fn main () { 
    use alone_ee::event_emitter::EventEmitter;
    let ee = EventEmitte::Stringr::new();

    let subscription1 = ee.on(Box::new(|event_data| {  // listener will be alive till subscription is alive 
        // do something
        println!("hello {}", event_data);
        Ok(())
    }));

    let _subscription2 = ee.once(Box::new(|event_data| {   // listener will be alive till subscription is alive or next emit will fired
        // do something
        println!("hello {} one more time", event_data);
        Ok(())
    }));

    ee.emit("world1").unwrap();
    ee.emit("world2").unwrap();

    // you will see 
    //     "hello world1"
    //     "hello world1 one more time"
    //     "hello world2"

    drop(subscription1); // unbind the listener
    // _subscription2 will be removed automatically
}

Testing

$ cargo test --release

Benchmark

$ cargo bench

Dependencies

~115KB