Fork me on GitHub
#re-frame
<
2020-05-11
>
andre19:05:19

re-frisk 1.3.2 with cached subscriptions and fix for subscriptions dispose https://github.com/flexsurfer/re-frisk

👍 12
thelittlesipper19:05:53

Quick re-frame question: where a subscription is dereferenced matters in terms of performance, right? i.e.

(defn my-component [s] [:div @s])

;; this function is the "view" that gets rendered and may contain many components
(defn my-panel []
  [:<>
    [my-component (rf/subscribe [::subs/my-sub])]])
is preferred over
;; now only immutable data gets passed in
(defn my-component [s] [:div s])

;; this function is the "view" that gets rendered and may contain many components
(defn my-panel []
  [:<>
    [my-component @(rf/subscribe [::subs/my-sub])]]))
?

andre19:05:46

i would say yes, i'm old school so I always create subs like this

(defn my-component [] 
 (let [s (rf/subscribe [::subs/my-sub])]
  (fn []
   [:div @s])))

;; this function is the "view" that gets rendered and may contain many components
(defn my-panel []
  [:<>
    [my-component]])

andre19:05:26

in that case you won't have cached creations

thelittlesipper19:05:25

In the case where the data is deref'd before being passed to the component, right?

andre19:05:40

subscribe outside renderer and deref inside renderer , that's ,my rule 🙂 (edited: but not for others, because of cache)

andre19:05:40

in my projects i use this defview macro ,so I don't need to think about deref at all https://github.com/flexsurfer/re-frame-steroid#usage

Shima21:05:53

Hi I have a circular dependency error while trying to change the active-page in my app There is an event a in namespace A (related to active page A) that need to call on API success when the active page is B and also There is an event b in namespace B (related to active page B) that need to call on API fail when the active page is A Is there any other solution except refactoring?

p-himik03:05:03

Maybe kee-frame can help you. Also, you can use the event IDs without requiring namespaces that register the corresponding event handlers directly from the namespaces that use the events. Just make sure that the namespaces are included somewhere.

👍 4
Lu22:05:46

An easy fix would be to call your event with the full qualified namespace rather than requiring the namespace and doing ::mn/my-event. Just don’t use the require and do :my.namespace/my-event

👍 4