3 unstable releases

0.2.1 Nov 4, 2023
0.2.0 Nov 1, 2023
0.1.0 Nov 1, 2023

#482 in Operating systems

MIT license

10KB
176 lines

🐍 SSSignals: Simple, Synchronous Reactive Signals for Rust

License GitHub issues Build status

SSSignals is a lightweight Rust library that provides simple, synchronous reactive signals. Signals are a powerful way to react to changes in values and design event-driven systems. With SSSignals, you can easily incorporate reactive programming into your Rust applications.

[Request a feature/Report a bug]

Features

  • 📡 Signal Creation: Create signals to hold values of any data type.
  • 🔄 Value Change Callbacks: Register callbacks that are triggered when the signal's value changes.
  • 🗺 Value Transformation: Map the signal's value to a new value using a provided mapping function.
  • 🎯 Trait Implementations: Implements common Rust traits such as Display, Debug, and Default.

Usage

use sssignals::Signal;

fn main() {
    let mut signal = Signal::new(42);

    signal.on_change(|new, old| {
        println!("Value changed from {} to {}", old, new);
    });

    signal.set(43); // Prints "Value changed from 42 to 43"

    println!("{}", signal); // Prints "Signal(43)"
}

Installation

Run cargo add sssignals or add the following to your Cargo.toml file:

[dependencies]
sssignals = "*"

Documentation

For detailed information on how to use SSSignals, please refer to the official documentation.

Contributing

We welcome contributions from the open-source community. If you'd like to report a bug, request a feature, or contribute to the project, you can use the set templates.

License

This project is licensed under the MIT License - see the LICENSE file for details.

No runtime deps