   ; sync from reference for the first time
   (dispatch-signal [::on-reset @r])
 
+  #_(println "1 DATA ATOM WATCHES = " (pr-str (count (.-watches r))))
+
   ; sync model from reference
   (add-watch r
              model

                         :else
                         (app-reconcile model action)))))))

(defcard-rg
  counter-with-history
  (fn [data-atom _]
    (let [app (carry/app (-> counter/spec
                             (add-atom-sync data-atom)))    ; <-- connect devcards atom
          [_ app-view] (carry-reagent/connect app counter/view-model counter/view)]
      ((:dispatch-signal app) :on-start)
      app-view))

  (atom (:initial-model counter/spec))                      ; <-- create devcards atom with initial model value

  {:inspect-data true
   :history      true})

; TODO: remove previous watches on hot reloads? they may leak memory by holding onto the old app instances

;;;;;;;;;;;;;;;;;;;;;;;; Figwheel stuff
(defn before-jsload

             r
             (fn [_key _ref _old-state new-state]
               (when (not= @r new-state)
                 (reset! r new-state))))

  #_(println "2 DATA ATOM WATCHES = " (pr-str (count (.-watches r)))))

(defn -unconnect-atom
  [r model]
  (remove-watch r model)
  (remove-watch model r))

(defn add-atom-sync
  "Carry middleware.
