Skip to content
Tomas Drencak edited this page May 13, 2018 · 20 revisions

Welcome to the statecharts wiki!

Problem definition

Statecharts library tries to solve the problem of describing complex UI programs. Currently we are focusing mainly on re-frame integration.

Re-frame is an excellent library. It manages the state of the application in form of the immutable database. Immutable database is then projected into HTML code using react/reagent libraries.

Problems begins when there are a lot of different screens and components which displays several parts of the application database all with different lifecycles. For instance uppon entering the page we need to change URL, uppon leaving we may want to persist current settings into browser storage etc...

Page can have several entry events (like goto-page, show-user-detail, set-data-filter) where you can put a middleware. But to detect leaving the page you have to cover all (possible future) other events which can cause the page leave.

FSM and Statecharts

There are several sources on the internet idicating that Finite state machines (FSM) and Statecharts can be successfuly used for UI description:

FSM is flat mathematical model of computation. It consists of states and transitions. All states are on the same level. Finite state machine for light bulb

FSMs works great on small models, but suffers from combinatorial explosion with addition of new states. Simply, there are too many arrows between states.

This is the place where statecharts comes to the rescue. Statecharts are finite state machines, where each state can be hierarchically composed of another states.

CD player

Further description can be found on Statecharts page.

Problems with Re-frame/Redux/Vuex

Statecharts library

Features include:

  • Works with immutable structures
  • Seamless integration with re-frame
  • All effects are described as datastructures.
  • re-frame effects can be directly used

DSL

API

Examples

Cookbook

Clone this wiki locally