Fork me on GitHub
#re-frame
<
2016-01-05
>
firinne02:01:29

Hey all, is there a good way to do data normalization for a re-frame db, similar to what is done in Om next

firinne02:01:54

scratch that

firinne02:01:01

figured it out

surreal.analysis02:01:07

I'm working on a simple clone of Retrospectus, and I'm wondering what the right / pretty way to switch between two very similar, but slightly different, options would be.

surreal.analysis02:01:14

Specifically, if someone has voted something up

surreal.analysis02:01:28

I want to change the appearance of the button, and make pressing that button vote things down

surreal.analysis02:01:30

(defn vote-button
  [retrospective comment]
  (let [voted? (:voted? comment)
        btn-class (if voted? "btn-warning" "btn-primary")
        btn-value (if voted? "-" "+")
        btn-dispatch (if voted? :downvote :upvote)]
    [:button.btn.btn-circle
     {:class btn-class
      :on-click #(dispatch [btn-dispatch retrospective comment])}
     btn-value]
    ))

surreal.analysis02:01:49

That's what I have, but wasn't sure if there was a way to simplify the large let block

kauko15:01:07

@firinne: sounds interesting, how'd you figure it out?

mccraigmccraig16:01:24

@surreal.analysis: it might be clearer in that case to skip the let altogether and just have two separate branches of an (if (:voted? comment) ...)