re-frame

Oli Solomons 2024-02-21T15:52:10.784719Z

Hello! Sorry if this has been asked before, but I couldn't find anything. I wanted to ask about using the reagent reaction macro vs dynamic subscriptions for something like this:

(rf/reg-sub
 ::weather-today-impl
 (fn [_ [day place]]
   (rf/subscribe [::weather day place]))
 identity)

(rf/reg-sub
 ::weather-today
 (fn [_]
   (rf/subscribe [::weather-today-impl]
                 [(rf/subscribe [::day])
                  (rf/subscribe [::place])]))
 identity)
VS
(rf/reg-sub
 ::weather-today
 (fn [_]
   (reaction
    @(rf/subscribe [::weather
                    @(rf/subscribe [::day])
                    @(rf/subscribe [::place])])))
 identity)

Oli Solomons 2024-02-21T15:53:15.594819Z

Obviously the first one is more vervose, but maybe it's more idiomatic or performant?

p-himik 2024-02-21T16:17:31.395979Z

I'd use reg-sub-raw. Both more idiomatic and performant.

Oli Solomons 2024-02-21T16:18:03.352109Z

reg-sub-raw + the reaction macro?

p-himik 2024-02-21T16:44:22.705219Z

Yep. Or a regular underefed sub since it's also a reaction.

Oli Solomons 2024-02-21T16:45:09.054049Z

Ok, thanks for you help!

👍 1
p-himik 2024-02-21T16:56:50.420039Z

Ah, but note that if you do deref anything, you still have to wrap everything in a reaction.

👍 1