What is bireactive?
Bireactive is a signals-style reactive system where edges run both ways. An ordinary reactive value is read-only downstream: you write a source, and everything derived from it recomputes. Here a derived value can also be written — the engine runs the derivation backward to update its sources.
import { cell } from "bireactive";
const celsius = cell(20);
const fahrenheit = celsius.lens(
c => (c * 9) / 5 + 32, // forward
f => ((f - 32) * 5) / 9, // backward
);
fahrenheit.value; // 68
fahrenheit.value = 212; // write the derived end…
celsius.value; // 100 — …and the source updates to match
New here? Start with the Getting Started guide. The live demo gallery shows these ideas in motion.
What can it do?
The library is organized into a handful of domains, each a group in this API reference:
Reactivity
The reactive core: writable cells, read-only derived values, side-effecting effects, and the bidirectional lens. Cell.merge folds many writers into one source; network builds constraint-style sub-graphs; store gives a deep, lens-backed proxy over nested state; and batch groups writes.
Values
Typed value cells with field lenses and domain operators, so point.x or
color.lightness is itself a writable cell. Includes Num, Vec,
Box, Color, Str, Bool, Range,
Matrix, Transform, Pose, Tri, Field,
Flags, Arr, Reg, Canvas, and Audio.
You do not need to use value classes, but they are a convenient way to create value types with well-known methods and cross-type lenses that reads left-to-right.
Lenses
Free-function lenses that compose values into writable derived views: the midpoint mean of points, a mix or crossfade, geometric relations, point-cloud fits, and numerical solvers.
Animation
Time-based motion: spring physics, tween interpolation, and generator-driven animators.
Shapes
Drawable geometric primitives for building diagrams and visualizations.
Rendering
Getting values onto the screen: SVG Diagrams, DOM attribute binding, syntax-highlighted code, and animatable tex math typesetting.
Utilities
Assorted helpers, including tree walking and assertions.