Pre-beta, under heavy active development: the API changes often and nothing here is stable yet.

Spar

Spar beside Treflex

Treflex is a runtime for front-end state and the work that runs on it (requests, timers, live connections, multi-step flows), with Solid-style signals and bindings for React and Solid. This page sets its model beside Spar's, from Treflex's own README and reference (actions.md, restart-and-records.md). Both keep work out of components; they differ in where the work lives and how two pieces of work on the same thing relate.

QuestionTreflexSpar
Where work livesOn an entity in the state tree (an object with an $Id); it runs while no view shows itIn an Effect on a service; the store (Store.Tag) holds the state, a reducer per action
How state changesAn action is a generator that writes the entity's draft directlyAn action's reducer returns the next state; an Effect sends commands as its work goes
Reaching the outside worldYields declared effects; the runtime calls the implementation, or a stub in a testEffect services in the Effect's requirements, provided as layers; a test provides other layers
Two actions on one entityTake turns: an action holds its entity until it finishes, so a second one waitsNever wait for each other unless the Effect says so (a Semaphore); each command applies at once
A repeat while the first runsleading drops the repeat; latest stops the one runningFiberHandle.run with onlyIfMissing ignores the repeat; plain FiberHandle.run stops the one running
Is it running?inFlight(action, owner)A field in the state that the Effect sets at its start and end, so the view can read it
A command that does not fitWritten as code in the action; Treflex's refusals are for code that breaks its rules (a write outside the action)Written as code in the Effect, before it sends the command
Surviving a reloadState, timers and connections save to one JSON string; cut-off work is reportedA saved store (layerSaved) comes back from the device; an outbox channel resends what was not confirmed
Removing the ownerRemoving an entity stops its work, timers and connectionsA store beside a component closes with it; its fibers stop with its scope
Seeing what happenedA record stream and an activity logOne timeline of commands, UI state and routes, each with its trace; time travel and forks in the devtools

What each makes impossible

  • Treflex: an entity changing under an action while that action waits (the hold), and work stopping because its view went away.
  • Spar: state that changes outside a reducer, work that runs twice (one Effect in a FiberHandle ignores or replaces a repeat), and an older answer landing over a newer one (queries numbering their requests).

Where they differ in spirit

Treflex makes the action the unit: it holds its entity, runs step by step, and the runtime can pause, cancel, record and restore it between steps. Spar makes the state the unit: every change is one command applied at once, and async work is a plain Effect that sends commands as it goes. Treflex queues a second click behind the first; in Spar the Effect says what a second click does, with Effect's own tools: a FiberHandle that ignores it or replaces the first run, or a Semaphore that queues it.