This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-01-05
Channels
- # admin-announcements (183)
- # aws (30)
- # beginners (22)
- # boot (301)
- # cider (19)
- # cljs-dev (3)
- # cljsrn (23)
- # clojars (15)
- # clojure (136)
- # clojure-italy (8)
- # clojure-nl (4)
- # clojure-russia (19)
- # clojured (10)
- # clojurescript (134)
- # component (48)
- # cursive (7)
- # datavis (4)
- # datomic (50)
- # devcards (6)
- # events (9)
- # jobs (1)
- # ldnclj (10)
- # lein-figwheel (19)
- # leiningen (1)
- # luminus (16)
- # off-topic (5)
- # om (151)
- # proton (60)
- # re-frame (10)
- # reagent (25)
- # remote-jobs (1)
- # slack-help (3)
- # spacemacs (1)
- # vim (1)
Hey all, is there a good way to do data normalization for a re-frame db, similar to what is done in Om next
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.
Specifically, if someone has voted something up
I want to change the appearance of the button, and make pressing that button vote things down
(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]
))
That's what I have, but wasn't sure if there was a way to simplify the large let block
@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) ...)