Fork me on GitHub
#reagent
<
2017-09-11
>
mrchance11:09:10

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

mrchance11:09:39

I am using adapt-react-class to wrap the components

mrchance12:09:30

Got it, you can just wrap (reagent/as-element ...) around it 🙂

bherrmann14:09:54

With this in my atom {:orders '( {:order-id 721 :steps { :step-set #{ 3 4 7 } } } ) }

bherrmann14:09:08

What is the best way to remove '4' from the step-set? without damaging any of the surrounding data/collections

bherrmann15:09:20

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)

bherrmann15:09:48

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.

juhoteperi15:09:07

@bherrmann Make :orders map indexed by :order-id and use update-in [:orders 721 :steps :step-set] disj 4

bherrmann15:09:15

@juhoteperi You certainly nailed my problem, using a list in a deeply nested structure is probably my mistake

bherrmann15:09:27

I should probably only stick to maps, vectors in state land? only use sets and lists at leafs?

juhoteperi15:09:41

Yes, that is usually good idea

juhoteperi15:09:06

And also, I only use vectors, no lists