Note: This post is a collection of notes and resources for my learning. Feel free to bookmark and check back occasionally as this post will be updated every now and then.
Since watching the learn state machines with David K. Piano on YouTube, I have been intrigued about state machinces and the issues they help alleviate.
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.
So it the most common example, a form can move from an idle state to a loading state and a loading state to either a successful or error state. You shouldn't get into an successful state without transitioning through the loading state. And more importantly, you shouldn't be able to hit the submit button when not in the idle state or error state.
Formally, finite state machines have five parts:
- A finite number of states
- A finite number of events
- An initial state
- A transition function that determines the next state given the current state and event
- A (possibly empty) set of final states
via XState docs