Fork me on GitHub

Finally got around to publishing, a cookies fx handler for re-frame. Any feedback welcome 🙂


@superstructor: Great, thanks for publishing those - I’ll take a look tomorrow. If you want to add them to the external resources docs page that would be great, if not I can do it later. Awesome that you’re using the google closure library, it would be great if eventually we have an fx handler for all of the useful parts of it so new users (and me) don’t have to think about how to use them with re-frame.


New version of re-com. We called it v1.0.0 It has one annoying backwards-incompatible change (sorry):


@mikethompson thanks for the heads up about this chan 🙂


I know this has been answered before but I am not really happy with the answer (use functions that operate on db). What I would like is to use values of subscriptions as input to a handler. Previously this was easily achieved by having each subscription just refer to a function that operated on db and then reuse that function in the handler (the previously suggested answer). In 0.8.0 this no longer works well since the input to most subscriptions is no longer db but other subscriptions. A ”leaf subscription” that depends on other subscriptions is therefore not trivially calculated from the value of db. Therefore what I am doing currently is to subscribe to the subscriptions I need in the handler and then pass them when I fire the event. But this is not very clean since the component that contains the dispatcher does not actually depend on those subs apart from when firing the event. How are you guys solving this? Is there a clean way of doing it or could it be implemented in re-frame.core?


One way of solving it would be to have a function that took a subscription vector but did not return a subscription but just a dereferenced value directly. Not exactly pure but could be quite useful if used carefully?


i need to implement a simple counter without using re-rendering any component which using it, how can i do that ?


I used reagent atom but unfortunately i ran into an infinite loop


@lxsameer I don't understand the question. Are you saying you just need to store a numeric value somewhere?


@vikeri: can you not do the same as pre-0.8 and just use reg-sub-raw instead of reg-sub?


@shaun-mahood Yes I could, the new concept of subscriptions depending on other subscriptions have significantly improved a lot of things though so that is not really an option for me.


Curious, what does "subscriptions depending on other subscriptions" mean? I haven't used 0.8.0


@vikeri: If you have some example code of what you have to do now and what you wish it would do, or something that could help me more easily understand what you want to do, I'm happy to take a look and see if I can come up with any ideas. No guarantees though 🙂


@shaun-mahood Lets say I wan’t to get the value of the subscription :footer-counts here:


That function does not have app-db as input but instead [todos completed] so to get the value of :footer-counts I would first have to calculate :todos and :completed-count individually. While this might be easy in this example it quickly turns cumbersome when the level of nesting grows.


@vikeri: Ok cool, I'll take a look later today and let you know if I can think of any ideas.


I mean, you can store any value in the db, you don't need to subscribe to it.. but then you won't see it in your UI. Are you sure you need something like that?


@andre: I've not been getting anything in my subs section in re-frisk, but it seems like everything else works fine. Is there anything additional I should do to get this working?


@andre: Nevermind, it looks like I just need to have that sub seen by a function defined using def-view and it becomes visible. Although I think I found something else - it looks like the def-view macro doesn't support comments the same way defn does, I get an error if I just do a straight replacement.

Pablo Fernandez22:10:51

Any ideas why (re-frame/subscribe [:name]) in here: would throw "Cannot read property 'call' of undefined"

Pablo Fernandez22:10:14

It’s the same code as in the template but all in one file.


Does it work if you change it to this?

(defn main-panel []
  (let [name (re-frame/subscribe [:name])]
    (fn [name]
      [:div "Hello from " @name])))


@vikeri: Here's my best attempt at how I would solve your problem with passing db through subs

Pablo Fernandez23:10:51

It looks like like 64 of subs.cljc is having the problem. (handler-fn app-db query-v) is may be returning nil when it shouldn't


@pupeno: Worth a shot 🙂 I copy and pasted just that code into a file and it runs fine for me with no errors.

Pablo Fernandez23:10:36

It is the lein template, so, it should be fine.

Pablo Fernandez23:10:49

But when I’m running it inside an electron app, it doesn’t work.


Ok that makes more sense 🙂


Yeah, even though I have no reason for it, you're the 3rd person this week having problems with cljs in electron - no idea why but it seems to be a theme.


What are you doing different now from your isomorphic blog posts?

Pablo Fernandez23:10:12

shaun-mahood you mean in general?

Pablo Fernandez23:10:29

or regarding this error?


@pupeno: Mainly relating to the error - normally if someone had a problem with anything like this I'd point them to your blog posts. Though I'm also curious 🙂

Pablo Fernandez23:10:12

Hahaha… I’m doing something completely different right now… just trying to get re-frame to play nicely inside electron.

Pablo Fernandez23:10:49

I just noticed electron came with old libraries of many things, so, I upgrade them, but that wasn’t it. Funnily enough, I don’t have a backtrace now, although I have the same error.


Wish I could help, but I'm totally clueless. I look forward to the blog post when you figure it out though!