Skip to content

Instantly share code, notes, and snippets.

@monyschuk
monyschuk / StateMachine.swift
Last active September 26, 2022 15:59
Simple Swift FSM
//: Playground - noun: a place where people can play
import UIKit
/// A finite state machine
final class FSM<State, Transition>: ObservableObject where State: Hashable, Transition: Hashable {
/// current state
@Published private(set) var state: State
/// state transition graph