Fork me on GitHub

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!


Excellent! Thanks for feedback. Always good to hear


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

 (fn [db [_ key]]
   (reaction (get @db key))))


@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.


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


@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


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


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.


@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.


@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.


@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


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


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


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


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


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