 (defn on-env-time-interval []
   (swap! state assoc-in [:env :time] (poly/js-now)))
 
-;; (defn on-gui-button-click [e]
-;;   (mutate-gui-click-count!))
-
 
 ;; -----------------------------------------------------------------------------
 ;; Event Subscriptions
 
-;; (defonce setup-event-take-backs!
-;;   (poly/take-back! (second (poly/listen-put! js/window :key)) on-env-keyboard-key))
-
-(defonce setup-event-take-backs!
-  (do
-    (poly/take-back! (get-event-channel :env-keyboard-key) on-env-keyboard-key)
-    (poly/take-back! (get-event-channel :env-mouse-move) on-env-mouse-move)
-  true))
-
-(defonce setup-fps!
-  (poly/listen-fps! on-env-frames-per-second))
+(defn setup-event-subscriptions! []
+  (swap! state assoc-in [:app :measure-fps?] true)
+  (poly/listen-fps! on-env-frames-per-second)
+  (poly/take-back! (get-event-channel :env-keyboard-key) on-env-keyboard-key)
+  (poly/take-back! (get-event-channel :env-mouse-move) on-env-mouse-move))
+
+(defn teardown-event-subscriptions! []
+  (swap! state assoc-in [:app :measure-fps?] false))
 
 
 ;; -----------------------------------------------------------------------------
 ;; Timers
 
-(defonce interval-for-env-time
-  (js/setInterval on-env-time-interval 1000))  ; every second (1000 ms)
+;; (defonce interval-for-env-time
+;;   (js/setInterval on-env-time-interval 1000))  ; every second (1000 ms)
 
 
 ;; -----------------------------------------------------------------------------

  (atom
   {:app {:name "Spinning"
          :version "0.1.0"
          }
    :ech {:env-keyboard-key nil
          :env-mouse-click nil



;; -----------------------------------------------------------------------------
;; Init/Load/Setup/Teardown

(defn setup []
  (console/info "setup")
  (poly/set-title! (get-in @state [:app :name]))
  (setup-event-channels!)
  (setup-event-subscriptions!)
  (setup-simple-animation!))

(defn teardown []
  (console/info "teardown")
  (teardown-simple-animation!)
  (teardown-event-subscriptions!)
  (teardown-event-channels!))

(defn ^:export on-load []
  (console/info "on-load")
  (teardown)
  (setup))

(defn ^:export on-init []
  (console/info "on-init")
  ; Create a canvas element inside the "app" div.
  (setup)
  ;(inspect @state)
  )
