Usage

Reactive is a reactive programming framework for the browser. It gives you a small, predictable model of state, calculations, reverse calculations, control flow and effects, plus a plain DOM driver to project that model onto the page.

The idea

Most frameworks bundle a reactive core together with a large user-interface library: components, layout, widgets, styling. Reactive keeps only the core. It offers a simplified DOM driver that deals in tags, attributes and text. That makes it small, easy to reason about, and simple to drop into an existing page.

The result is a framework you plug in. Mount a reactive component into any element and leave the rest of the page exactly as it is.

Where it comes from

Reactive is a small, hand-written JavaScript library, built from scratch for the browser. Its model, reactive values with readable and writable halves, forward calculations, reverse calculations, and lock-aware readiness, is drawn from a larger reactive system, then refined and tuned to fit JavaScript. The result is a focused runtime you can read in an afternoon.

The runtime primitives live under one object, Reactive: State, Set, Mount, If, Reverse and the rest. Library modules are their own top-level globals: you declare one with Reactive.Module, then call it directly, such as Content.Title(...) or Maths.Add(...). The surface stays small and it runs straight in the browser with no build step and no imports.

What makes it different

Four choices set Reactive apart. Each links to its full page.

Asynchronous work, handled for you. Loading, errors and retry ride inside every value. A spinner appears around the region that waits, a failed value shows its message and a retry button, and the controls feeding an in-flight write disable themselves. You write the happy path and the framework supplies the rest.

Reversibility in place of event handlers. Interaction is a write. Setting a value runs a reverse back to state, so two-way binding, clicks, typing and retry collapse into one mechanism. You understand a control by reading the binding on it, right where it sits.

Mode-based programming. One definition runs under different modes. Bind different module implementations and the same component renders to the DOM, a PDF, or a 3-D scene, unchanged.

Drivers at the edge. Every connection to the outside world lives in a driver, so the program body stays pure forward code. The running state is plain data, so you can snapshot a program and resume it on another machine, where it reconnects to that machine's drivers.

Principles

Coding standards

Reactive programs are written in a deliberately small, strict subset of JavaScript. Keeping to it lets the framework read your program, reason about readiness, direction and identity for you, and keep the code tidy as it grows. The rules are few:

Concretely, the strict shape collapses boilerplate. A two-way binding to a field is a single dotted access rather than a hand-written pair of calculations:

// not this — nested calls, a raw Calculate, a manual field rewrite:
const name = Reactive.Binding(
  Reactive.Calculate(() => Reactive.Value(user).name),
  Reactive.Reverse((n) => Reactive.Set(user, { ...Reactive.Value(user), name: n })));

// this — dotted access is already a settable field, so the input is just:
Reactive.Input.Text(user.name);
The wrapping does the work: user.name reads the field and, because it carries its own writable half, an input bound to it writes straight back in one expression.