Skip to content

Rust library to facilitate event-driven programming.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

agersant/squeak

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Squeak

build_badge crates.io_badge docs_badge

Squeak is a zero-dependency Rust library to facilitate event-driven programming.

Examples

use squeak::{Delegate, Response};

let on_damage_received = Delegate::new();
on_damage_received.subscribe(|amount| {
    println!("Received {amount} damage");
    Response::StaySubscribed
});

on_damage_received.broadcast(16); // Prints "Received 16 damage"
on_damage_received.broadcast(14); // Prints "Received 14 damage"
on_damage_received.broadcast(28); // Prints "Received 28 damage"
use squeak::{Observable, Response};

let mut health = Observable::new(100);
health.subscribe(|updated_health| {
    println!("Health is now {updated_health}");
    Response::StaySubscribed
});

health.mutate(|h| *h -= 10); // Prints "Health is now 90"
health.mutate(|h| *h -= 5);  // Prints "Health is now 85"
health.mutate(|h| *h += 25); // Prints "Health is now 110"

About

Rust library to facilitate event-driven programming.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages