Squeak is a zero-dependency Rust library allowing execution of callbacks in response to values being broadcast or mutated.
```rust use squeak::{Delegate, Response};
let ondamagereceived = Delegate::new(); ondamagereceived.subscribe(|amount| { println!("Received {amount} damage"); Response::StaySubscribed });
ondamagereceived.broadcast(16); // Prints "Received 16 damage" ondamagereceived.broadcast(14); // Prints "Received 14 damage" ondamagereceived.broadcast(28); // Prints "Received 28 damage" ```
```rust use squeak::{Observable, Response};
let mut health = Observable::new(100); health.subscribe(|updatedhealth| { println!("Health is now {updatedhealth}"); 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" ```