| Crates.io | tokio-signals |
| lib.rs | tokio-signals |
| version | 0.1.0 |
| created_at | 2025-11-16 08:17:36.660751+00 |
| updated_at | 2025-11-16 08:17:36.660751+00 |
| description | Implements pub/sub Signals in Rust |
| homepage | |
| repository | https://github.com/tokio-signals |
| max_upload_size | |
| id | 1935330 |
| size | 9,090 |
Simple implementation of a Signal using Tokio's watch channel
use tokio_signals::signal::Signal;
fn main() {
let count = Signal::new(0);
// Set count to 10
count.set(10);
let current_count = count.get();
println!("Current count: {}", current_count);
// Prints "Current count: 10"
// Subscribe to changes
count.subscribe(|new_value| {
println!("Count changed reactively: {}", new_value);
});
// Update count
count.set(20);
// Prints "Count changed reactively: 20"
}