Fork me on GitHub
#re-frame
<
2016-07-29
>
dignati11:07:02

Hey everybody 🙂 I just wanted to say thanks for re-frame. We now have 14k LOC of (front-end) clojurescript, all supported by re-frame and we are really happy with it!

mikethompson11:07:05

Excellent! Thanks for feedback. Always good to hear

si1413:07:51

I think this channel is a better place to ask than #C03S1L9DN :) are there any downsides of re-frame subscriptions like

(register-sub
 :get
 (fn [db [_ key]]
   (reaction (get @db key))))
?

lsnape13:07:51

@si14: the main benefit, for me at least, of subscriptions is that they neatly decouple the thing your subscribing to from the app-state. Using a subscription like the one above means you lose that benefit.. which is fine if you know the layout of your app-db isn’t going to change, but not something I’d be willing to sacrifice.

lsnape13:07:45

A common refactoring I’ve seen as my app-db has evolved has been switching from lists to maps. But because the subscription doesn’t care about the path or collection type, the changes I have to make are in most cases very small

si1414:07:26

@lsnape: thanks! The main reason why I feel the need for subscriptions like that is an abundance of trivial subscriptions in the code. It can be the case that I'm doing something wrong, of course

lsnape14:07:26

I know what you mean. Sometimes it can feel awfully repetitive writing specific cases where all you’re doing is a get. Something to be aware of though

shader14:07:48

I wrote a simple function to automatically create subscriptions for certain keys in my db. Makes the base case easy, and you can always replace them with a different definition later.

mikethompson14:07:51

@si14 It kinda depends on your app as to how much of an abundance of these simple getters you see. Problems with a generic getter: 1. The views now know about the structure of app-db. They hold path information. The entire reason for subscriptions is so that components ask for data with no knowledge of where it comes from. 2. Shortly, when 0.8.0 comes out, you'll be wanting to use reg-sub which provides effecient de-duplication of the signal graph (where that matters). The way you have written you generic getter subscription, it will fire every time db changes, for any reason whatsoever.

si1414:07:59

@mikethompson: yeah, I'm looking forward for 0.8.0 release! I will definitely need to reeducate myself about fetching data into the app, though.

danielcompton20:07:15

@si14: at one point we had partial subscriptions (analogous to partial functions) which we used to subscribe to a portion of the app-db tree and which took a key for their final parameter

danielpquinn22:07:22

Howdy all. I’m starting to play around with re-frame and so far it’s pretty fun to work with

danielpquinn22:07:37

Do I need to worry about “unsubscribing” from updates to my app-db?

danielpquinn23:07:28

Sometimes I want to grab an arbitrary value from the db and I end up doing something like this (let [something (subscribe [:something])] @something)

danielpquinn23:07:03

Will I create a memory leak if I create subscriptions willy-nilly whenever I need to access app-db?

danielpquinn23:07:15

nm, looks like I have homework to do. Reading through the reagent/ratom source his making my head spin