tokio-signals

Crates.iotokio-signals
lib.rstokio-signals
version0.1.0
created_at2025-11-16 08:17:36.660751+00
updated_at2025-11-16 08:17:36.660751+00
descriptionImplements pub/sub Signals in Rust
homepage
repositoryhttps://github.com/tokio-signals
max_upload_size
id1935330
size9,090
Cameron Dunn (dunncj)

documentation

README

tokio-signals

Simple implementation of a Signal using Tokio's watch channel

Usage

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"
}




Commit count: 0

cargo fmt