Fork me on GitHub
#re-frame
<
2016-10-17
>
superstructor00:10:40

Finally got around to publishing https://github.com/SMX-LTD/re-frame-cookie-fx#cookies-effects-handler-for-re-frame, a cookies fx handler for re-frame. Any feedback welcome 🙂

shaun-mahood05:10:40

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

mikethompson05:10:59

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

sandbags10:10:37

@mikethompson thanks for the heads up about this chan 🙂

vikeri10:10:48

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?

vikeri11:10:08

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?

lxsameer12:10:07

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

lxsameer12:10:42

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

kauko14:10:54

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

shaun-mahood14:10:18

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

vikeri14:10:01

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

kauko15:10:54

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

shaun-mahood15:10:25

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

vikeri15:10:53

@shaun-mahood Lets say I wan’t to get the value of the subscription :footer-counts here: https://github.com/Day8/re-frame/blob/master/examples/todomvc/src/todomvc/subs.cljs#L143

vikeri15:10:56

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.

shaun-mahood15:10:21

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

kauko16:10:35

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?

shaun-mahood20:10:28

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

shaun-mahood20:10:07

@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: https://gist.github.com/pupeno/4b37f11f2992747582165cbf790d6aaf#file-foo-cljs-L23 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.

shaun-mahood22:10:15

Does it work if you change it to this?

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

shaun-mahood22:10:36

@vikeri: Here's my best attempt at how I would solve your problem with passing db through subs https://gist.github.com/smahood/e5498ad569842f37d1313a68c17e1336

Pablo Fernandez22:10:00

@shaun-mahood it doesn’t fix it.

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

shaun-mahood23:10:44

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

shaun-mahood23:10:18

Ok that makes more sense 🙂

shaun-mahood23:10:27

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.

shaun-mahood23:10:03

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?

shaun-mahood23:10:39

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

shaun-mahood23:10:57

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