Fast, lightweight reactive state for Python
Project description
fastreactpy ⚡
Fast, lightweight reactive state library for Python.
fastreactpy brings React-like reactive state to Python with zero dependencies, minimal overhead, and a clean API.
🚀 Installation
pip install fastreactpy
🧠 Core Concepts
Signal
A signal is a reactive container for state.
from fastreactpy import signal
count = signal(0)
count()→ get valuecount(10)→ set value and notify subscribers
Effect
An effect automatically re-runs when the signals it uses change.
from fastreactpy import effect
@effect
def logger():
print("Count:", count())
✨ Basic Example
from fastreactpy import signal, effect
count = signal(0)
@effect
def print_count():
print("Count changed:", count())
count(5)
count(10)
Output:
Count changed: 0
Count changed: 5
Count changed: 10
📁 Sharing State Between Multiple Files
This is the most common real-world usage.
store.py (Shared State)
from fastreactpy import signal
count = signal(0)
user = signal("Guest")
logger.py (Reactions / Effects)
from fastreactpy import effect
from store import count, user
@effect
def log_count():
print("[logger] Count:", count())
@effect
def log_user():
print("[logger] User:", user())
main.py (Mutating State)
import logger # IMPORTANT: registers effects
from store import count, user
count(1)
user("Malahim")
count(5)
user("Alice")
Output:
[logger] Count: 0
[logger] User: Guest
[logger] Count: 1
[logger] User: Malahim
[logger] Count: 5
[logger] User: Alice
🧩 Multiple Effects on One Signal
from fastreactpy import effect
from store import count
@effect
def double():
print("Double:", count() * 2)
@effect
def square():
print("Square:", count() ** 2)
⚡ Why fastreactpy?
- Zero dependencies
- Extremely lightweight
- React-style mental model
- Automatic dependency tracking
- Works across files
- Ideal for CLIs, tools, and services
⚠️ Best Practices
- Keep shared signals in a single module (e.g.
store.py) - Always import modules that define effects
- Avoid heavy logic inside effects
- Use effects for side-effects only
🌐 Contact
Website: https://malahim.dev
Phone: +92 328 4671797
📄 License
MIT License © 2025 Malahim Haseeb
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastreactpy-0.0.3.tar.gz.
File metadata
- Download URL: fastreactpy-0.0.3.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5594f61154716073d601ca839723faf0597043ef3032855cbf99fcae5d9bfb6b
|
|
| MD5 |
d116cb82febb5964e6e4870c78f87196
|
|
| BLAKE2b-256 |
dca7a2f1212a7dc17ab79cba8a3f0ff5917d9b2ba976ff6c5ca5fe0304a81517
|
File details
Details for the file fastreactpy-0.0.3-py3-none-any.whl.
File metadata
- Download URL: fastreactpy-0.0.3-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
769f7e20d34e3532f72e9e5e32f4005e1cd06096e7953f9bc18863b19cc5bdf4
|
|
| MD5 |
dd876e6fb493f6e0c530f9a72e5731dd
|
|
| BLAKE2b-256 |
99b9c66ccbb6a3f69ba614853d81900bdc97f0230b4ef80dcc9f73adc50c958c
|