Some examples of state machine implementation using vanilla JS.
State Machine or finite-state machine (FSM) is a mathematical model of computation.
It is an abstract machine that can be in exactly one of a finite number of states at any given time.
The FSM can change from one state to another in response to some inputs; the change from one state to another is called a transition.
An FSM is defined by a list of its states, its initial state, and the inputs that trigger each transition.
We describe some possibilities of State Machine usage bellow.
Application code is located inside the folder with the same name of the example.
A turnstile is used to control access to an area.
The turnstile has two possible states: Locked and Unlocked.
Dispatch change the current state to the another defined.