This page is part of a static HTML representation of TriTarget.org at https://tritarget.org

Nano State Machine

Sukima17th September 2020 at 4:41pm

This is a nano implementation of the Simple State Machine idea for cases when all you need is just very simple state tracking.

See also, CSS based view states.

function transitionMachine(
  machine,
  state = machine.initial,
  event
) {
  return machine.states[state].on?.[event]
    ?? machine.on?.[event]
    ?? state;
}