 
 (declare make-reaction)
 
-(defonce cached-reactions (transient {}))
-
-(defn- get-sub-map [k]
-  (let [m (get cached-reactions k)]
-    (if-not (nil? m)
-      m
-      (let [m (transient {})]
-        (->> (assoc! cached-reactions k m)
-             (set! cached-reactions))
-        m))))
-
-(defn- cached-reaction [f k1 k2 obj destroy]
-  (let [m (get-sub-map k1)
-        r (get m k2)]
+(def ^{:private true :const true} cache-key "reaction-cache")
+
+(defn- cached-reaction [f o k obj destroy]
+  (let [m (aget o cache-key)
+        m (if (nil? m) {} m)
+        r (get m k)]
     (if-not (nil? r)
       (-deref r)
       (if (nil? *ratom-context*)

  (-deref [this]
    (if-some [r reaction]
      (-deref r)
      (cached-reaction #(apply f args) (goog/getUid f) args this nil)))

  IEquiv
  (-equiv [_ other]

        nocache (if (nil? no-cache) false no-cache)
        reaction (Reaction. f nil dirty nil nil
                            runner on-set on-dispose nocache)]
    (when-not (nil? capture)
      (when-some [c (aget capture cache-key)]
        (aset reaction cache-key c)))
    ;; TODO: get rid of reaction-id
    (when-some [rid (some-> capture .-reaction-id)]
      (set! (.-reaction-id reaction) rid))
    (when-not (nil? derefed)
