Where should you store state and how should it be managed in a ClojureScript application? Take the following code for example - it's a "game" where you travel either down or left.
(ns cljsfiddle) ; initialise the state (set! (.-x js/window) 0) (set! (.-y js/window) 0) ; state modifiers (defn inc-x! [value] (set! (.-x js/window) (inc (.-x js/window)))) (defn inc-y! [value] (set! (.-y js/window) (inc (.-y js/window)))) (.addEventListener js/window "keyup" (fn [event] (let [key-code (.-which event)] (cond (= key-code 49) (inc-x!) (= key-code 50) (inc-y!))) (print (.-x js/window) (.-y js/window))))