reactive-values
v1.0.19
Published
Lightweight reactive value library with support for deep equality and computed values.
Maintainers
Readme
Reactive Values
Description
Reactive Values is a lightweight JavaScript & TypeScript library designed to provide a simple and intuitive reactivity system. It allows you to define reactive values, listen to changes, and create computed values with minimal overhead.
Installation
npm install reactive-valuesQuick Start
Here’s how you can go from zero to reactive programming in seconds:
import { SignalValue, ComputedValue } from "reactive-values";
// Step 1: Create a reactive value
const counter = SignalValue(0);
// Step 2: Listen to changes
counter.effect((value) => {
console.log("Counter changed:", value);
});
// Step 3: Update the value
counter.set(1); // Console: "Counter changed: 1"
counter.set(2); // Console: "Counter changed: 2"
// Step 4: Create a computed value
const double = ComputedValue(() => counter() * 2);
double.effect((value) => {
console.log("Double is:", value);
});
// Updates automatically when counter changes
counter.set(3); // Console: "Counter changed: 3" and "Double is: 6"Documentation
Reactive Values Full documentation
License
This project is licensed under the MIT License - see the LICENSE file for details.
