This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-06
Channels
- # adventofcode (181)
- # aws (6)
- # beginners (112)
- # boot (38)
- # cider (11)
- # cljs-dev (12)
- # cljsrn (2)
- # clojure (187)
- # clojure-greece (31)
- # clojure-italy (19)
- # clojure-new-zealand (1)
- # clojure-poland (1)
- # clojure-spec (20)
- # clojure-uk (114)
- # clojurescript (97)
- # core-logic (25)
- # cursive (3)
- # data-science (17)
- # datascript (3)
- # datomic (23)
- # defnpodcast (1)
- # duct (5)
- # emacs (3)
- # fulcro (299)
- # graphql (108)
- # jobs (1)
- # juxt (4)
- # lein-figwheel (7)
- # leiningen (1)
- # lumo (9)
- # nrepl (2)
- # off-topic (10)
- # om (2)
- # onyx (36)
- # pedestal (1)
- # perun (3)
- # re-frame (14)
- # reagent (12)
- # ring (2)
- # rum (11)
- # shadow-cljs (6)
- # spacemacs (4)
- # unrepl (8)
Been playing with Reagent for the first time checking out its reactive behavior and I am wondering if I am missing something. Or maybe my expectations are off. I created an artificial chain of reactions to assess “glitch” avoidance, but there seems to be no risk of that because reactions do not cache calculations; they always recalculate and recursively so so no glitches can arise (but calculations are repeated):
`(let [x (atom 0)
ast (atom {:foo {:bar 1000
:baz 100}})
abar (reagent/cursor ast [:foo :bar])
abaz (reagent/cursor ast [:foo :baz])
a (reagent/track
(fn []
(println :calc-aaa )
(+ @abar (* 10 @x)))
42)
b (ra/make-reaction
(fn []
(println :calc-b)
(+ @a (* 2 @x))))
z (ra/make-reaction
(fn []
(println :calc-z)
(+ @b @a @x)))]
(println :x @x :a @a :z @z)
(println :bumping-x!!!!!)
(swap! x inc)
(println :x @x :a @a :z @z)
(println :bumping-abaz!!!!!)
(swap! abaz inc)
(println :x @x :a @a :z @z)
)
`In the second bumping I targeted a cursor not in any calculation, but the whole chain of recalculations ran anyway. Am I doing this wrong or is Reagent not meant to be abused this way? 🙂
I should mention that my first concern is that, since there are two paths back to “a” I see “calc-aaa” twice at each bump, and the second concern is that I see a full chain of calculations on the second bump.
When I use a vector for my {:class} of an object, the results are an invalid comma-separated string as the class of the div/object. Is this a bug, or a version thing?
@worlds-endless I thought it just had to be a string?
[:div {:class "first second"} ]
The front page says it's there "The :class attribute can accept either a collection or a string." https://github.com/reagent-project/reagent
and it was added quite a while back https://github.com/reagent-project/reagent/commit/5045046f6a2e53961bc1a0c5f5e7022c294f8aad