Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Last active March 2, 2017 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deque-blog/30597748ffe738c11c05e1701c7a7507 to your computer and use it in GitHub Desktop.
Save deque-blog/30597748ffe738c11c05e1701c7a7507 to your computer and use it in GitHub Desktop.
(defonce app-state (reagent/atom (logic/new-game)))
(def current-turn (reaction (logic/current-turn @app-state)))
(defn send-event! [e] (swap! app-state logic/handle-event e))
(defn handle-event
"Dispath the event to the game logic, yielding a new game"
[game event]
(cond
(= event :restart) (new-game)
(= event :undo) (undo-last-move game)
:else (play-move game event)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment