Reaktiv – Simple Reactive Programming for Python

1 month ago 6

reaktiv logo

Reactive declarative state management for Python — automatic dependency tracking and reactive updates for your application state.

Python Version PyPI Version PyPI Downloads Documentation Status License Checked with pyright

What is reaktiv?

reaktiv is a reactive declarative state management library for Python that lets you declare relationships between your data instead of manually wiring updates. When data changes, everything that depends on it updates automatically — eliminating a whole class of bugs where you forget to update dependent state.

Think of it as a spreadsheet for your Python application: change a cell, and all formulas using that cell recalculate instantly.

Why Use reaktiv?

reaktiv solves common pain points in state management:

  • Eliminates manual state synchronization - No more forgetting to update derived values
  • Reduces bugs - Ensures consistent state throughout your application
  • Simplifies code - Declare relationships once, not every time data changes
  • Improves performance - Only recomputes what actually needs to change

Learn more about why you should use reaktiv →

Features

  • Automatic state propagation: Change a value once, and all dependent computations update automatically
  • Efficient updates: Only the necessary parts are recomputed (fine‑grained reactivity)
  • Zero external dependencies: Lightweight and easy to incorporate into any project
  • Type-safe: Fully annotated for clarity and maintainability
  • Lazy and memoized: Computations run only when needed and cache until dependencies change

Quick Start

reaktiv is built around three core primitives:

  1. Signals: Store values and notify dependents when they change
  2. Computed Signals: Derive values that automatically update when dependencies change
  3. Effects: Run side effects when signals or computed signals change
from reaktiv import Signal, Computed, Effect # Reactive data sources name = Signal("Alice") age = Signal(30) # Reactive derived value greeting = Computed(lambda: f"Hello, {name()}! You are {age()} years old.") # Reactive side effect (retain a reference!) greeting_effect = Effect(lambda: print(f"Updated: {greeting()}")) # Update base data — everything reacts automatically name.set("Bob") # Prints: Updated: Hello, Bob! You are 30 years old. age.set(31) # Prints: Updated: Hello, Bob! You are 31 years old.

Documentation

Read Entire Article