Model Finite Number of State and Events with State Machines

Segun Adebayo
InstructorSegun Adebayo
Share this video with your friends

Social Share Links

Send Tweet

A state machine is a method of modeling a finite number of states and events. When an event is sent, actions and transitions are triggered within the machine to update it's state.

Here we model a a state machine for a check box. There are unchecked and checked states with a click event that transitions the machine between these two states.

Instructor: [0:00] A state machine is a method of modeling a system that has finite number of states and events. [0:06] At any given state, when the machine is sent an event, it causes the machine to execute actions and transitions. In this example here, we're modeling the native checkbox element. Let's assume the checkbox starts in the unchecked state. Clicking the checkbox takes you to the checked state. If you click the checkbox again, it takes us back to the unchecked state.

[0:28] This is what we mean when we say a state machine has finite number of states. In this contract example, we have unchecked and checked state, and a single event called Click.

[0:40] Events in the state machine can trigger transitions as well as actions and side effects.

[0:46] Join me on this journey. We're going to try to build a robust pin input component. We'll see you on the other side.