Skip to content

Instantly share code, notes, and snippets.

@stormwild
Last active May 8, 2024 06:11
Show Gist options
  • Save stormwild/68f3aad93e75d27c3064b51c10194a23 to your computer and use it in GitHub Desktop.
Save stormwild/68f3aad93e75d27c3064b51c10194a23 to your computer and use it in GitHub Desktop.

State Machine

Implementing a simple state machine library in JavaScript

Statechart Driven UI Components with Zag.js | egghead.io

Statechart Driven UI Components with Zag.js | egghead.io

Understanding State Machines, Part 1: What Are They? - YouTube

Understanding State Machines, Part 2: Why Use Them? - YouTube

How to express state machines?

State Transition Diagrams

Understanding State Machines, Part 3: Mealy and Moore Machines - YouTube

Mealy and Moore

Understanding State Machines, Part 4: Harel State Machines - YouTube

Harel State Charts

  1. Hierarchy

    parent states

  2. Orthogonality

    Parallelism

    In an oven state machine, the oven can be off or baking; inside baking it can be heating or idling.

    At the same same when the oven is off the oven light is off but on when baking (heating or idling) the oven light is on

    stateDiagram-v2
        state Oven {
            OvenOff --> Baking: Bake Pressed
            Baking --> OvenOff: Off Pressed
        }
    
        state Baking {
            Heating --> Idling: Too Hot
            Idling --> Heating: Too Cold
        }
    
        state OvenLight {
            LightOff --> LightOn: Bake Pressed
            LightOn --> LightOff: Off Pressed
        }
    
  3. Broadcasting

JavaScript State Machines

Do you speak JavaScript? / What is a state machine and how to make one - YouTube

The Rise Of The State Machines — Smashing Magazine

Mastering the State Machine Pattern 🔄: A Technical Dive into Modeling Complex Processes and Workflows 🚀 | by Solidity Academy | Medium

PluralSight

C# Design Patterns: State - Pluralsight

Design Patterns Library - Pluralsight

Building State Machines in .NET - Pluralsight

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment