This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-09-11
Channels
- # aleph (4)
- # beginners (68)
- # boot (21)
- # chestnut (1)
- # cljs-dev (72)
- # clojure (64)
- # clojure-austin (9)
- # clojure-dusseldorf (16)
- # clojure-gamedev (2)
- # clojure-italy (32)
- # clojure-russia (80)
- # clojure-spec (9)
- # clojure-uk (20)
- # clojurescript (105)
- # cursive (5)
- # data-science (5)
- # datomic (23)
- # defnpodcast (3)
- # emacs (22)
- # fulcro (2)
- # graphql (63)
- # hoplon (7)
- # lein-figwheel (17)
- # lumo (63)
- # mount (2)
- # nrepl (4)
- # off-topic (66)
- # om (6)
- # onyx (3)
- # portkey (54)
- # re-frame (12)
- # reagent (12)
- # specter (42)
- # uncomplicate (1)
- # unrepl (38)
- # vim (9)
- # yada (3)
Hi, I am using react bootstrap, and trying to implement a panel... https://react-bootstrap.github.io/components.html#panels-heading <- This says I can just pass another component as a header, but how do I accomplish the same in cljs? Simply passing a hiccups vector here doesn't work
With this in my atom {:orders '( {:order-id 721 :steps { :step-set #{ 3 4 7 } } } ) }
What is the best way to remove '4' from the step-set? without damaging any of the surrounding data/collections
My solution works, but it feels like an anti-pattern writ large.
(def state {:orders '( {:order-id 721 :steps { :step-set #{ 3 4 7 } } } ) })
(defn remove-step [state order-id step]
(let [orders (:orders state)
order (first (filter #(= order-id (:order-id %)) orders))
steps (:steps order)
step-set (:step-set steps)
new-stepset (disj step-set step-num)
new-steps (assoc steps :step-set new-stepset)
new-order (assoc order :steps new-steps)
orders-without-order (filter #(not (= order-id (:order-id %))) orders)
new-orders (conj orders-without-order new-order)]
(assoc state :orders new-orders)))
(remove-step state 721 4)
I feel like I want to change a light bulb in a room, but I have to dissassemble my entire house and reassemble it to do so.
@bherrmann Make :orders
map indexed by :order-id
and use update-in [:orders 721 :steps :step-set] disj 4
@juhoteperi You certainly nailed my problem, using a list in a deeply nested structure is probably my mistake
I should probably only stick to maps, vectors in state land? only use sets and lists at leafs?
Yes, that is usually good idea
And also, I only use vectors, no lists