     (let [oldstate state
           res (capture-derefed f this)
           derefed (-captured this)]
-      (when (not= derefed watching)
+      (when-not (arr-eq derefed watching)
         (._update-watching this derefed))
       (set! dirtyness clean)
       (when-not nocache?


(defn- notify-deref-watcher! [derefable]
  (when-some [obj *ratom-context*]
    (let [captured (.-cljsCaptured obj)]
      (set! (.-cljsCaptured obj)
            (if (nil? captured)
              (let [old (.-watching obj)]
                (if (and (== 1 (count old))
                         (identical? derefable (first old)))
                  ;; Optimize common case of one deref
                  old
                  #{derefable}))
              (conj captured derefable))))))

(def reaction-counter 0)

(defn reaction-key [r]
  (if-some [k (.-reaction-id r)]
    k
    (->> reaction-counter inc

  (-write writer (str "#<" s " "))
  (pr-writer (binding [*ratom-context* nil] (-deref a)) writer opts)
  (-write writer ">"))


;;; Atom

