Fork me on GitHub
#re-frame
<
2018-07-11
>
Drew Verlee01:07:54

When using re-frame with react native is there anything special to consider?

jeaye05:07:09

Nope. re-frame operates above that level.

👍 4
Drew Verlee13:07:28

I recall you saying that. I just wanted to be super sure i understood you correctly. When i was reading the docs they seemed so geared towards web development that i assumed their was some coupling there. Very happy its not, makes the entire thing way more useful. that and it was the best question i could come up with at 9:45pm -_-

p-himik06:07:34

I have a patter similar to this one throughout may of my views:

(let [a @(subscribe [:a])
      b @(subscribe [:b a])]
...)
I'd like to refactor it into a single subscription. I don't want to just compose the functions in subscriptions because this way the new sub will be run each time db is changed. I only want it to be run when either [:a] or [:b a] changes. I was thinking about returning a reaction as a signal fn. Something like:
(reg-sub :a-b
  (fn [_]
    (reagent/reaction @(subscribe [:b @(subscribe [:a]))))
  (fn [b _]
    b))
Does anyone have any thoughts?

nenadalm17:07:24

maybe:

(reg-sub
 :a-b
 (fn [_]
   (subscribe [:a]))
 (fn [a]
   (compute-b a)))
? (https://github.com/Day8/re-frame/blob/master/docs/SubscriptionInfographic.md)

nenadalm17:07:59

sorry - I think I misunderstood - ignore the comment above.

nenadalm17:07:30

is :a-b supposed to return just b? If so, it should look like:

(reg-sub
 :a-b
 (fn [_]
   (subscribe [:a]))
 (fn [a]
   (compute-a-b a)))

p-himik18:07:16

The problem here is that :b is a rather complicated subscription. It has different signals that depend on a (and other parameters in reality). So, using just the computation function for :b is not that simple.

p-himik18:07:24

The solution with a reaction appears to be working though.

eoliphant17:07:11

hi I guess this is more of a cljs-ajax question, but I’m using the xhrio effects with the default transit encoding. I’ve just noticed that the default deserailization for some types (uuid’s, large integers, etc) is to transit specific types, not say the ‘default’ uuid in clojurescript. Anyone have any quick workarounds for this?