Fork me on GitHub
#reagent
<
2019-11-22
>
Edo18:11:30

Hey everyone, I'm new to clojure(script). I've started learning few days ago and I have a doubt (inside this thread) https://i.imgur.com/BimmpLv.pnghttps://i.imgur.com/BimmpLv.png

Edo18:11:51

So, I have that function in the right called handle-save

Edo18:11:16

and inside handle-save I've used let to grab to define new-status-cols which is a vector

Edo19:11:07

and now I'd like to write the swap function to update new-status-cols in my app-state, replacing status-cols

Edo19:11:16

can someone please ❤️ give me a hand on this?

p-himik19:11:12

(swap! state/app-state
       (fn [state]
         (let [board-idx (first (keep-indexed
                                  (fn [i b]
                                    (when (= board-name (:name b))
                                      i))
                                  (:boards state)))]
           (assoc-in state [:boards board-idx :is-add-status-col-mod-open] false))))

p-himik19:11:22

Didn't test but should work.

Edo19:11:14

thanks a lot! even if it doesn't work, gives me a good idea on how to do it 🙂 🚀

p-himik19:11:46

Of course it will error out if it can't found the board by its name. Also, it requires a vector there, or something that's indexed by a number. Because of this, I prefer to have a map of IDs to the corresponding elements and a separate vector of ordered IDs if you need the order.

Edo19:11:43

will try to improve it that way ❤️

Edo19:11:10

small steps 🙂 need to do a lot of gym 😛

p-himik19:11:38

Just keep at it and you'll get there in no time. 👍

Edo19:11:44

hope so mate 🙂 have a nice weekend