v0.19.3 is live
Reactive State.
Zero
Chaos.
A declarative state management library for Python.
True lazy evaluation. Fine-grained reactivity.
Updates are pushed to invalidate. Data is pulled on demand.
Synchronous. Glitch-free.
Fresh
Stale (Dirty)
Live Code
Declare Relationships, Not Steps.
Define how your data is related, and reaktiv handles the updates automatically.
1. The Signal
from reaktiv import Signal
# 1. Create a Signal
count = Signal(0)
# 2. Update it
# Writing is cheap (just invalidates)
count.set(5) 2. The Computed
from reaktiv import Signal, Computed
count = Signal(0)
# No calculation happens here!
doubled = Computed(
lambda: count() * 2
)
# Calculation happens NOW (Pull)
print(doubled()) 3. The Effect
from reaktiv import Signal, Computed, Effect
count = Signal(0)
doubled = Computed(lambda: count() * 2)
# ⚠️ Important: Keep a reference!
# Otherwise GC deletes the listener.
watcher = Effect(
lambda: print(doubled())
)
# Updates trigger the effect
count.set(6) 4. LinkedSignal
from reaktiv import Signal, LinkedSignal
count = Signal(0)
# Writable, but auto-resets when
# dependency changes.
sync = LinkedSignal(
lambda: count() * 10
)
sync.set(999) # Override manually
count.set(2) # sync resets to 20! lazy evaluation
linked signals
type safe
fine-grained
batch updates
memoization
Try it yourself
Running live in your browser with PyScript.
main.py
OutputLoading PyScript...