This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-30
Channels
- # announcements (20)
- # asami (26)
- # babashka (10)
- # babashka-sci-dev (18)
- # beginners (81)
- # biff (6)
- # calva (6)
- # cider (1)
- # clerk (1)
- # clj-kondo (34)
- # clojure (50)
- # clojure-belgium (1)
- # clojure-berlin (6)
- # clojure-europe (20)
- # clojure-nl (1)
- # clojure-norway (22)
- # clojure-uk (2)
- # clojurescript (1)
- # clr (4)
- # community-development (3)
- # data-science (8)
- # datomic (3)
- # gratitude (1)
- # honeysql (6)
- # instaparse (2)
- # jobs (1)
- # jobs-discuss (13)
- # kaocha (7)
- # london-clojurians (1)
- # lsp (6)
- # malli (8)
- # matcher-combinators (9)
- # missionary (3)
- # nbb (8)
- # off-topic (20)
- # pathom (16)
- # polylith (2)
- # practicalli (3)
- # rdf (1)
- # re-frame (7)
- # reagent (3)
- # releases (2)
- # reveal (6)
- # rewrite-clj (22)
- # shadow-cljs (64)
- # tools-build (7)
- # xtdb (13)
I have a question with reagent atoms/cursors: I have a function I have to run a lot. I want to check a map ratom to see if the key exists, and if it does not exist, add it to the atom. Is there a 'fast' way to get the value of a ratom, without triggering any of the watchers etc? Alternatively I can create a cursor on the fly and dereference it, but I feel like that is probably more expensive. Anyways, I guess my question can be summed up: what is the fastest/most performant way to check if a ratom has a specific key?
"Get and update" should be expressed with swap!
, which is a single operation. Even when there's no update.
IIRC, changing a ratom's value multiple times within a single frame won't actually trigger any computations - it will simply mark the dependent reactions as dirty. The recomputations will be done once the reactions are queried, so at the end of the frame.
@U031G98S4GG I went through this with some animation code, the way is (.-state my-atom)