Skip to content

Commit

Permalink
perf: replace high-freq updated atom with volatile
Browse files Browse the repository at this point in the history
  • Loading branch information
RCmerci committed Dec 12, 2024
1 parent ebbb53c commit 7de6349
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/main/frontend/state.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
[promesa.core :as p]
[rum.core :as rum]))

(defonce *profile-state
(atom {}))
(defonce *profile-state (volatile! {}))

(defonce *db-worker (atom nil))

Expand Down Expand Up @@ -830,7 +829,7 @@ Similar to re-frame subscriptions"

(defn set-state!
[path value & {:keys [path-in-sub-atom]}]
(swap! *profile-state update path inc)
(vswap! *profile-state update path inc)
(let [path-coll? (coll? path)
get-fn (if path-coll? get-in get)
s (get-fn @state path)
Expand Down Expand Up @@ -862,7 +861,7 @@ Similar to re-frame subscriptions"

(defn update-state!
[path f & {:keys [path-in-sub-atom]}]
(swap! *profile-state update path inc)
(vswap! *profile-state update path inc)
(let [path-coll? (coll? path)
get-fn (if path-coll? get-in get)
s (get-fn @state path)
Expand Down

0 comments on commit 7de6349

Please sign in to comment.