Reactive signals

Formula compiler and runtime Internals covers how formulas evaluate in dependency order. This is one layer further down — the actual primitive every reactive value in Formo is built from.

The Signal primitive

Every reactive value — a property, mouse.x, time, a tag count — is backed by a real Signal. A signal holds three things: its current value, a version number that increments on every change, and a set of subscribers (the things that need to know when it changes).

Reading a signal during formula evaluation automatically registers that formula as a subscriber — there's no manual subscribe call anywhere in a formula you write. Writing a new value notifies every subscriber to mark itself dirty, and schedules a flush.

One real optimization worth knowing: a signal skips its own change notification entirely if the new value is identical to the old one. Setting a property to the value it already holds doesn't ripple out to anything that depends on it — no dirty marking, no re-evaluation, nothing happens.

Prototype-inherited formula context

Each formula's execution context is built with Object.create() off a shared prototype, rather than assembling a fresh object by spreading properties together every time. It's a small, deliberate detail, but it's part of why the hot evaluation path — potentially dozens of formulas recalculating every frame — stays cheap: building a context is a prototype-chain hookup, not an allocation-heavy object copy.

Why vector geometry uses typed arrays

This isn't specific to formulas, but it's part of the same performance story: a vector network's own point data — x, y, and corner radius per vertex — lives in a stride-4 Float32Array rather than an array of plain JS objects. Reading a coordinate is an index into a flat numeric buffer, not a property lookup on an object, which matters when that data gets touched on every frame of an animation.

For the dependency graph itself — evaluation order, cycle detection, batching multiple changes into one pass — see Formula compiler and runtime internals; the Signal primitive here is what that graph is actually built out of.

On this page

Formo

The browser studio where drawings become animations, toys, and games. Your files, open HTML export, nothing to install.