Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
clojure state machine
state (atom :continue)
;; state event new state
state-machine {:continue {:pause :paused
:halt :halting}
:paused {:resume :resuming
:halt :halting}
:resuming {:continue :continue}
:halting {:halt :halted}}
step-state (fn [transition]
(swap! state #(get-in state-machine [% transition])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.