Fork me on GitHub
#re-frame
<
2015-12-18
>
danielgrosse10:12:45

I have a list of sessions, which a getting updated by an re-frame handler, now I want to set an session as active by referencing it in a designated map. There should be additions to the map, which are doesn’t have to occur in the original map. But the referenced map should get all updates, which are happening in the sessions list.

{:sessions
 {1 {:id   1
     :name "Name1"}}
 {2 {:id   2
     :name "Name2"}}
 :active-session
 {:id              1
  :name            "Name1"
  :additional-info "Info"}}
How could I achive this with reactions?

Chris O’Donnell13:12:14

@danielgrosse: You could store idents rather than the actual data and update your subscriptions accordingly. For example, your active session there would just be {:id 1} and you'd have a function in your subscription that grabs the session with a particular id. Like (get-in db [:sessions id]).

danielgrosse13:12:45

Thanks @codonnell thats how I done it now.

sashton14:12:30

At https://github.com/Day8/re-com/blob/master/src/re_demo/radio_button.cljs#L33, the comment states ;; Notice the ugly "doall". What is the reason for the doall? In the code for v-box, the children are put (into [] children), so I would assume it will be fully evaluated at that point. Am I missing something?

danielgrosse14:12:55

How can I specify different keys for the react components? I get warnings for children with the same key. I use re-com for element generation.

danielgrosse14:12:49

@sashton I had to use doall, because react throws some errors when not.

sashton14:12:06

yeah, i've seen that error before as well. but in the case of v-box, it looks to me like the children are being put into a vector internally anyway, so they would be fully evalueated

danielgrosse14:12:29

I had a v-box without it, and it works.

mikethompson17:12:26

@sashton: I can't remember why we did that. If I was doing it now, I'd probably do this:

[v-box
    :children (for [c ["red" "green" "blue"]]  ...

mikethompson17:12:33

children does not have to be vector, just an ISeq

sashton17:12:04

@mikethompson: thanks, that's what it looked like to me as well. glad to know i was understanding it