Fork me on GitHub

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)))
        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"} ]


If there is support for vector conversion, I’m not aware of it


The front page says it's there "The :class attribute can accept either a collection or a string."


you win then


Not sure what is the issue above in that case