shigunaru 0.0.1

A lightweight reactive signals library in Rust
Documentation
  • Coverage
  • 0%
    0 out of 27 items documented0 out of 18 items with examples
  • Size
  • Source code size: 37.97 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 466.22 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • tsukuricase/shigunaru
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Jalever

Shigunaru

A lightweight reactive signals library implemented in Rust.

Features

  • Simple reactive signal implementation
  • Computed signals with automatic dependency tracking
  • Lazy evaluation and caching for computed values
  • Subscription-based reactivity system
  • Clean and modular API

Installation

Add this to your Cargo.toml:

[dependencies]
shigunaru = "0.1.0"

Basic Usage

use shigunaru::{Signal, create_computed, create_effect};

// Create a signal with initial value
let counter = Signal::new(0);

// Use it directly
counter.set(5);
let value = *counter.get().borrow();

// Subscribe to changes
let counter_effect = counter.clone();
create_effect(
    move || {
        println!("Counter changed: {}", *counter_effect.get().borrow());
    },
    &counter,
);

// Change the signal value - will trigger the effect
counter.set(10);

Computed Signals

Computed signals derive their values from other signals and automatically update when dependencies change:

use shigunaru::{Signal, create_computed};

// Base signal
let count = Signal::new(1);

// Create a computed signal
let count_for_computed = count.clone();
let doubled = create_computed(move || {
    *count_for_computed.get().borrow() * 2
});

// Initial computed value
assert_eq!(doubled.value(), 2);

// Update the source signal
count.set(5);

// Computed value automatically updates
assert_eq!(doubled.value(), 10);

Examples

See the examples directory for more usage examples:

  • counter.rs - Basic counter with computed values

Run an example with:

cargo run --example counter

Project Structure

shigunaru/
├── src/
│   ├── lib.rs         # Main API exports
│   ├── signal.rs      # Signal implementation
│   ├── computed.rs    # Computed signals
│   ├── effect.rs      # Effect system
│   ├── registry.rs    # Dependency tracking
│   └── tests/         # Unit tests
├── examples/          # Usage examples
└── tests/             # Integration tests

License

MIT