Status: Placeholder. Don't bother reading yet.
Colloquial: I'd like re-frame to have a better story for programming in FSMs. I want to represent "Higher Order Behaviour" which currently gets "smeared" across multiple event handlers.
Many high level aspects of SPAs are best modelled explicitly as an FSM. First, an app must gather X from the user, but if they press cancel, then return to showing Y, but otherwise move on to do activity Z. It is quite natural to model such overall decisions and the UIs involved as an FSM.
Many low level aspects of SPAs are best modelled explicitly as FSM too. The simple act of GETing from a server involves various states, including waiting, and failed, and timed-out, and retrying and succeeded.
BUT you need the power of a fully expressive state machine.
You need orthogonal state, guards, hierarchical state, history, etc.
Back in 1987, Harel identified the set of features required - anything less
and your tool will not be expressive enough to do the job.
Harel also insisted that statecharts was a visual
formalism, so tooling is also important.
Beware of the Turing tar-pit in which everything is possible but nothing of interest is easy.
-- Alan Perlis
State machines are appealing because:
Also, Why Developers Never Use State Machines https://www.skorks.com/2011/09/why-developers-never-use-state-machines/
Technical elements:
machine-id
app-db
(at :machines
or a configurable place?)id
of the state machine targeted:effects
reg-view
which will make it much easier to describe UI in machine data structureEvents model user intent, not implementation details.
So, we DO NOT want events that talk about FSM or triggers etc because that's an implementation detail.
Instead, we want
But event handlers should know about XXX
Types of triggers:
app-db
has changedWhat if we didn't even use FSM and used Behaviour Trees instead?
Behaviour trees are more composable. A better match for a data-oriented design.
Links And Notes:
Previously CLJS :
Other Attempts:
Fractal UI components using snabbdom, Harel statecharts, and event emitters
Understanding the Second Generation of Behavior Trees (video)
TLA+
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close